-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
45 lines (40 loc) · 1.28 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const gVar = {
checkStatus: false
};
chrome.tabs.onCreated.addListener(function(tab) {
gVar.checkStatus = false;
testeEventThis();
});
chrome.tabs.onActivated.addListener(function(activeInfo) {
gVar.checkStatus = false;
testeEventThis();
});
// chrome.tabs.onUpdated.addListener(function(activeInfo) {
// gVar.checkStatus = false;
// testeEventThis();
// });
chrome.browserAction.onClicked.addListener(function(tab) {
gVar.checkStatus = !gVar.checkStatus;
testeEventThis();
});
function testeEventThis() {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
if (gVar.checkStatus) {
chrome.browserAction.setIcon({path: 'images/valuedot_active_32.png'});
chrome.tabs.executeScript(
tabs[0].id,
{code: `
document.body.style.filter = "saturate(100%) grayscale(100%) contrast(100%) brightness(1.1)";
document.body.style.transition = "0.3s all ease-in-out";
`});
} else {
chrome.browserAction.setIcon({path: 'images/valuedot_32.png'});
chrome.tabs.executeScript(
tabs[0].id,
{code: `
document.body.style.filter = "";
document.body.style.transition = "0.05s all linear";
`});
}
});
}