theme.getCurrent()
Retourne le theme utilisé actuellement sous la forme d'un objet 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.
Syntaxe
js
var getting = browser.theme.getCurrent(
windowId, // integer
);
Paramètres
windowIdFacultatif-
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é.
Valeur retournée
Un objet Promise. L'objet Promise sera résolu avec un objet 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.
Compatibilité des navigateurs
Chargement…
Exemples
Obtient les propriétés des couleurs accentcolor et toolbar dans le thème actuel.
js
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();