forked from mdn/webextensions-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextpage.js
More file actions
29 lines (24 loc) · 858 Bytes
/
extpage.js
File metadata and controls
29 lines (24 loc) · 858 Bytes
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
let activeThemeEl = document.querySelector("#active-theme");
let readmeEl = document.querySelector("#read-me");
function updateThemeInfo(info) {
activeThemeEl.textContent = `${info.name} (${info.id})`;
}
// Include the README.md file content into the test page.
fetch("/README.md").then(r => r.text()).then(text => {
readmeEl.textContent = text;
});
// Set active theme info element content on page load.
browser.management.getAll().then(addons => {
updateThemeInfo(addons.find(addon => addon.type == "theme" && addon.enabled));
});
// Show pageAction icon on the extension page.
browser.tabs.getCurrent().then(tabInfo => {
browser.pageAction.show(tabInfo.id);
});
// Update active theme info when a theme is enabled.
browser.management.onEnabled.addListener(info => {
if (info.type !== "theme") {
return;
}
updateThemeInfo(info);
});