Gets the currently used theme as a Theme
object. The arguments available in the color object are listed in the properties of the color.
This is an asynchronous function that returns a Promise
.
var getting = browser.theme.getCurrent( windowId // integer )
windowId
Optional
integer
. The ID of a window. If this is provided, the theme applied on that window will be provided. If it is omitted the theme applied on the last focused window will be provided.A Promise
. The promise will be fulfilled with a theme.Theme
object representing the theme applied to the given window. If no extension-supplied theme has been applied to the given window, it will be fulfilled with an empty object.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
getCurrent |
No |
No |
58 |
? |
No |
No |
? |
? |
No |
? |
? |
? |
Gets the properties frame
and toolbar
colors of the current theme
function getStyle(themeInfo) { if (themeInfo.colors) { console.log("accent color : " + themeInfo.colors.frame); console.log("toolbar : " + themeInfo.colors.toolbar); } } async function getCurrentThemeInfo() { var themeInfo = await browser.theme.getCurrent(); getStyle(themeInfo); } getCurrentThemeInfo();
© 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/getCurrent