theme.getCurrent()
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
.
Syntax
var getting = browser.theme.getCurrent(
windowId // integer
)
Parameters
Return value
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.
Browser compatibility
Report problems with this compatibility data on GitHubwebextensions-desktop | webextensions-mobile | |||||
---|---|---|---|---|---|---|
getCurrent | ChromeNo supportNo | EdgeNo supportNo | FirefoxFull support58 | OperaNo supportNo | SafariNo supportNo | Firefox for AndroidNo supportNo |
Legend
- Full support
- Full support
- No support
- No support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Examples
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();