-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloader.js
48 lines (41 loc) · 1.41 KB
/
loader.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
const script = document.createElement("script");
script.src = chrome.runtime.getURL("index.js");
document.body.appendChild(script);
console.log("[RoAdditions] running roadditions extension on local side :D");
function getSetting(name) {
return new Promise(function (resolve, reject) {
// Load user's preferences
chrome.storage.sync.get(name, function (result) {
if (chrome.runtime.lastError) {
reject(chrome.runtime.lastError);
console.log(
"[RoAdditions] looks like it failed... insufficient perms maybe???"
);
} else {
// Return the setting value
resolve(result[name]);
}
});
});
}
function setSetting(name, val) {
// Save user's preferences
let obj = {};
obj[name] = val;
chrome.storage.sync.set(obj, function () {
console.log("[RoAdditions] Setting saved:", obj);
});
}
getSetting("playbtn")
.then(function (value) {
// Use candoplaybtn here
if (value) {
const script = document.createElement("script");
script.src = chrome.runtime.getURL("playbtn.js");
document.body.appendChild(script);
}
console.log("[RoAdditions] playbtn setting value:", value);
})
.catch(function (error) {
console.error("[RoAdditions] Error loading setting:", error);
});