-
Notifications
You must be signed in to change notification settings - Fork 1
/
background.js
31 lines (29 loc) · 794 Bytes
/
background.js
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
var startService = function() {
chrome.storage.sync.get({
serviceStatus: ""
}, function(items) {
if (items.serviceStatus == "start") {
chrome.tabs.executeScript(null, {file: "injection.js"});
} else {
chrome.tabs.executeScript(null, {file: "rejection.js"});
}
});
}
window.addEventListener("storage", startService, false);
document.addEventListener("DOMContentLoaded", function() {
startService();
function install_notice() {
if (localStorage.getItem('install_time'))
return;
var now = new Date().getTime();
localStorage.setItem('install_time', now);
chrome.tabs.create({url: "customize.html"});
}
install_notice();
});
chrome.tabs.onActivated.addListener(function() {
startService();
});
chrome.tabs.onUpdated.addListener(function() {
startService();
});