-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcore.js
53 lines (46 loc) · 1.07 KB
/
core.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
let BsPort;
let logs = [];
// Communication: Acts as middleman between popup.js and content.js
function handleCS(p) {
BsPort = p;
BsPort.postMessage({ connection: "BG Connected" });
BsPort.onMessage.addListener((m) => {
if (m.msgType && m.msgType == "POPUP") {
logs = m.logs;
}
console.log(m);
});
}
function handlePU(m, sender) {
console.log(m);
if (m.msgType == "POPUP") {
browser.runtime.sendMessage({msgType: "POPUP", logs: logs});
}
if (m.msgType == "SETTING") {
BsPort.postMessage(m);
}
}
browser.runtime.onConnect.addListener(handleCS);
browser.runtime.onMessage.addListener(handlePU);
browser.tabs.onUpdated.addListener(() => {BsPort.postMessage({msgType: "PageUpdated"});});
/* REWORK
function darkMode(tab) {
if (SettingsThemeDark) {
console.log("Dark Theme Enabled")
browser.scripting.insertCSS({
target: {
tabId: tab,
},
files: ["./themes/dark.css"],
});
}
else {
console.log("Dark Theme Disabled")
browser.scripting.removeCSS({
target: {
tabId: tab,
},
files: ["./themes/dark.css"],
});
}
}*/