--- title: theme.getCurrent() slug: Mozilla/Add-ons/WebExtensions/API/theme/getCurrent tags: - API - Add-ons - Extensions - Method - Reference - Theme - WebExtensions - getCurrent translation_of: Mozilla/Add-ons/WebExtensions/API/theme/getCurrent ---
Retourne le theme utilisé actuellement sous la forme d'un objet {{WebExtAPIRef("theme.Theme", "Theme")}}. Les arguments disponible dans l'objet couleur sont listés dans les propriétés de la couleur.
Il s'agit d'une fonction asynchrone qui renvoie un objet Promise
.
var getting = browser.theme.getCurrent( windowId // integer )
windowId
{{optional_inline}}integer
. L'ID d'une fenêtre. Si cela est indiqué, le thème appliqué sur cette fenêtre sera retourné. Sinon le thème appliqué sur la dernière fenêtre active sera retourné.Un objet Promise
. L'objet Promise sera résolu avec un objet {{WebExtAPIRef("theme.Theme")}} représentant le thème appliqué à la fenêtre spécifiée. Si aucun thème provenant d'une extension a été appliqué, l'objet Promise sera résolu avec un objet vide.
{{Compat("webextensions.api.theme.getCurrent", 10)}}
Obtient les propriétés des couleurs accentcolor
et toolbar
dans le thème actuel.
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();
{{WebExtExamples}}