forked from Stigmatoz/web-activity-time-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
33 lines (29 loc) · 908 Bytes
/
background.js
File metadata and controls
33 lines (29 loc) · 908 Bytes
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
31
32
33
window.onload = function () {
window.timer = new WebTimer();
chrome.tabs.onActivated.addListener(function (info) {
chrome.tabs.get(info.tabId, function (tab) {
window.timer.addTab(tab);
});
});
};
var WebTimer = function () { };
WebTimer.prototype = {
tabs: [],
activeTab: {},
addTab: function (tab) {
if (this.isValidPage(tab) === true) {
if (tab.id && (tab.id != 0)) {
this.tabs = this.tabs || [];
this.tabs.push(tab.url);
this.activeTab = tab.url;
}
}
},
isValidPage: function (tab) {
if (!tab || !tab.url || (tab.url.indexOf('http:') == -1 && tab.url.indexOf('https:') == -1)
|| tab.url.indexOf('chrome://') !== -1
|| tab.url.indexOf('chrome-extension://') !== -1)
return false;
return true;
}
};