mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-17 23:08:33 +02:00
Add per-window theme example: private browsing theme (#307)
This commit is contained in:
25
private-browsing-theme/background.js
Normal file
25
private-browsing-theme/background.js
Normal file
@@ -0,0 +1,25 @@
|
||||
browser.windows.onCreated.addListener(themeWindow);
|
||||
|
||||
// Theme all currently open windows
|
||||
browser.windows.getAll().then(wins => wins.forEach(themeWindow));
|
||||
|
||||
function themeWindow(window) {
|
||||
// Check if the window is in private browsing
|
||||
if (window.incognito) {
|
||||
browser.theme.update(window.id, {
|
||||
images: {
|
||||
headerURL: "",
|
||||
},
|
||||
colors: {
|
||||
accentcolor: "black",
|
||||
textcolor: "white",
|
||||
toolbar: "#333",
|
||||
toolbar_text: "white"
|
||||
}
|
||||
});
|
||||
}
|
||||
// Reset to the default theme otherwise
|
||||
else {
|
||||
browser.theme.reset(window.id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user