forked from Ultrawenis/WayFarer-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
52 lines (46 loc) · 1.3 KB
/
main.js
File metadata and controls
52 lines (46 loc) · 1.3 KB
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
getData();
function getData(){
chrome.storage.local.get(null, function (data){
if (data["options_set"] === undefined || data["options_set"] < settingsVersion)
setTimeout(getData, 20); //Really fast but not instant
else
init(data);
});
}
function init(settings){
if (settings["useMods"] === false){
return;
//Do not apply any mods
}
document.addEventListener('DOMContentLoaded', function(){
var head = document.getElementsByTagName("head")[0];
var setInject = document.createElement("script");
setInject.innerText = "var settings = " + JSON.stringify(settings) + "; var extURL = \"" + chrome.runtime.getURL("") + "\";";
head.appendChild(setInject);
switch (window.location.pathname){
case "/nominations":
modNominationPage(settings);
break;
case "/review":
case "/review#":
modReviewPage(settings);
break;
case "/profile":
modProfilePage(settings);
break;
}
//Always
modHeader(settings);
modAll(settings);
});
}
//Helper functions
function addPageJS(file, defer = false){
var newScript = document.createElement("script");
newScript.src = chrome.extension.getURL("pageJs/" + file);
if (defer){
newScript.setAttribute("defer", "");
}
newScript.setAttribute("type", "text/javascript");
document.getElementsByTagName("head")[0].appendChild(newScript);
}