-
Notifications
You must be signed in to change notification settings - Fork 1
/
background.js
37 lines (33 loc) · 1.05 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
function toggleTheme() {
browser.management.getAll().then(extensions => {
for (let extension of extensions) {
if (extension.id !== '[email protected]') continue;
if (extension.enabled) {
browser.management.get("[email protected]").then(info => {
browser.management.setEnabled("[email protected]", !info.enabled);
})
} else {
browser.management.get("[email protected]").then(info => {
browser.management.setEnabled("[email protected]", !info.enabled);
});
};
};
});
}
browser.action.onClicked.addListener(toggleTheme);
function toggleSystemTheme() {
browser.management.get("[email protected]").then(info => {
browser.management.setEnabled("[email protected]", !info.enabled);
});
}
browser.menus.create({
id: "use-systemtheme",
type: "normal",
title: "Use system theme (auto)",
contexts: ["action"],
icons: {
"16": "icons/browser.svg",
"32": "icons/browser.svg"
},
});
browser.menus.onClicked.addListener(toggleSystemTheme);