-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
59 lines (50 loc) · 1.46 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
46
47
48
49
50
51
52
53
54
55
56
57
58
browser.browserAction.onClicked.addListener(callTheKiller);
browser.tabs.onUpdated.addListener(callTheKillerBack);
browser.tabs.onActivated.addListener(callTheKillerBack);
function callTheKiller() {
checkCommunityAndTerrorize(releaseTheKillerAndWarnTheTown);
};
function callTheKillerBack() {
checkCommunityAndTerrorize(releaseTheKiller);
};
function checkCommunityAndTerrorize(callback) {
browser.tabs.query({'active': true, 'lastFocusedWindow': true}, function (tabs) {
let url = tabs[0].url;
if (url.includes("https://") || url.includes("http://")) {
callback();
}
})
};
function validateUrl() {
var url = getTabUrl();
};
function releaseTheKiller() {
browser.tabs.executeScript(null, { file: "./kill-elm-dead.js" });
};
function releaseTheKillerAndWarnTheTown() {
browser.storage.local.get(["crimeScene"], function(result) {
result.crimeScene ? coverItUp() : warnTheTown();
browser.storage.local.set({ "crimeScene": !result.crimeScene });
releaseTheKiller();
});
};
function warnTheTown() {
browser.browserAction.setIcon({
path : {
"16": "images/elm-lives16.png",
"32": "images/elm-lives32.png",
"48": "images/elm-lives48.png",
"128": "images/elm-lives128.png"
}
});
}
function coverItUp() {
browser.browserAction.setIcon({
path : {
"16": "images/elm-dies16.png",
"32": "images/elm-dies32.png",
"48": "images/elm-dies48.png",
"128": "images/elm-dies128.png"
}
});
}