Movatterモバイル変換


[0]ホーム

URL:


  1. Mozilla
  2. Add-ons
  3. Browser extensions
  4. JavaScript APIs
  5. theme
  6. theme.getCurrent()

theme.getCurrent()

Gets the current theme as aTheme object.

This is an asynchronous function that returns aPromise.

Syntax

js
let getting = browser.theme.getCurrent(  windowId    // integer)

Parameters

windowIdOptional

integer. The ID of a window. If this is provided, the theme resolved is the one applied to that window. If it is omitted, the theme resolved is the one applied to the most recently focused window.

Return value

APromise. The promise is fulfilled with atheme.Theme object representing the theme applied to the given window. If no extension-supplied theme has been applied to the given window, it is fulfilled with an empty object.

Examples

Gets the propertiesframe andtoolbar colors of the current theme:

js
function getStyle(themeInfo) {  if (themeInfo.colors) {    console.log(`accent color: ${themeInfo.colors.frame}`);    console.log(`toolbar: ${themeInfo.colors.toolbar}`);  }}async function getCurrentThemeInfo() {  const themeInfo = await browser.theme.getCurrent();  getStyle(themeInfo);}getCurrentThemeInfo();

Example extensions

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp