-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent.js
More file actions
30 lines (24 loc) · 1.17 KB
/
content.js
File metadata and controls
30 lines (24 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
chrome.runtime.onMessage.addListener(processMessage);
var html = '<div class="docs-title-widget goog-inline-block" id="docs-title-widget timer-thing"><div class="docs-title-input-label" style="pointer-events: none; max-width: 621px;"><span id ="time-span"></span></div></div>';
$('.docs-activity-indicator-container').append(html);
// After json is sent to doc tab
function processMessage(message, sender, sendResponse){
console.log(message);
// If message sent to tab is to get visibility
if (message.visibilityRequest == 'true'){
var visibility = document.visibilityState;
sendResponse(visibility);
}
// If the message sent is used to update the time
else {
var hours = Math.floor(message.time / 3600);
var minutes = Math.floor((message.time - hours * 3600) / 60);
var seconds = Math.floor(message.time % 60);
var displayText = hours + " Hours " + minutes + " Minutes " + seconds + " Seconds";
if (message.state == "idle"){
displayText += ' - Idle';
}
document.getElementById("time-span").innerHTML = displayText;
}
}
// fix the on all tabs close case - afk case (5 min time out)