Updates the browser theme according to the content of given Theme
object.
browser.theme.update( windowId, // integer theme // object )
windowId
Optional
integer
. The ID of a window. If this is provided, the theme is applied only to that window. If it is omitted the theme is applied to all windows.theme
object
. A Theme
object specifying values for the UI elements you want to modify.Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
update |
No |
No |
55 |
? |
No |
No |
? |
? |
No |
? |
? |
? |
windowId |
No |
No |
57 |
? |
No |
No |
? |
? |
No |
? |
? |
? |
Sets the browser theme to use a sun graphic with complementary background color:
const suntheme = { images: { theme_frame: 'sun.jpg', }, colors: { frame: '#CF723F', tab_background_text: '#111', } }; browser.theme.update(suntheme);
Set the theme for just the currently focused window:
const day = { images: { theme_frame: 'sun.jpg', }, colors: { frame: '#CF723F', tab_background_text: '#111', } }; browser.menus.create({ id: "set-theme", title: "set theme", contexts: ["all"] }); async function updateThemeForCurrentWindow() { let currentWindow = await browser.windows.getLastFocused(); browser.theme.update(currentWindow.id, day); } browser.menus.onClicked.addListener(updateThemeForCurrentWindow);
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/theme/update