-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblacks.js
42 lines (37 loc) · 1.1 KB
/
blacks.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
var root = document.documentElement ;//|| document.head || document.querySelector("head");
var link = document.createElement("link");
link.setAttribute("type", "text/css");
link.setAttribute("id", "blacks");
link.setAttribute("rel", "stylesheet");
link.href = chrome.runtime.getURL("blacks.css");
root.appendChild(link);
blacks = document.location.host;
chrome.storage.sync.get([blacks], function (items){
if ( items[blacks] == false ) {
link.remove();
}
});
chrome.runtime.sendMessage({method: "getStatus"}, function(global_enabled) {
if(global_enabled){
chrome.storage.sync.get([blacks], function (items){
if ( items[blacks] ) {
root.appendChild(link);
chrome.storage.sync.set({[blacks]: true})
}
});
}else{
link.remove();
}
});
document.addEventListener("keydown", (e)=> {
if(e.ctrlKey && e.shiftKey && (e.key === "E")){
chrome.storage.sync.get([blacks], function (items){
if ( items[blacks] != false ) {
link.remove();
}else{
root.appendChild(link);
}
chrome.storage.sync.set({[blacks]: !items[blacks]})
});
}
});