MDN wants to learn about developers like you: https://qsurvey.mozilla.com/s3/MDN-survey

ここへジャンプ:

この記事はまだボランティアによって 日本語 に翻訳されていません。ぜひ MDN に参加して翻訳を手伝ってください!
この記事を English (US) で読むこともできます。

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

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.

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

ChromeEdgeFirefoxFirefox for AndroidOpera
Basic support No No58 No No

Examples

Gets the properties accentcolor and toolbar colors of the current theme

function getStyle(themeInfo) 
{
  if (themeInfo.colors) 
  {
    console.log("accent color : " +  themeInfo.colors.accentcolor);
    console.log("toolbar : " + themeInfo.colors.toolbar);
  }
}

async function getCurrentThemeInfo() 
{
  var themeInfo = await browser.theme.getCurrent();
  getStyle(themeInfo);
}

getCurrentThemeInfo();

Example extensions

ドキュメントのタグと貢献者

 このページの貢献者: hellosct1, wbamberg, ntim
 最終更新者: hellosct1,