theme.update() 编辑
Updates the browser theme according to the content of given Theme
object.
Syntax
browser.theme.update(
windowId, // integer
theme // object
)
Parameters
windowId
Optionalinteger
. The ID of a window. If this is provided, the theme is applied only to that window. If it is omitted the theme is applied to all windows.
theme
object
. ATheme
object specifying values for the UI elements you want to modify.
Browser compatibility
BCD tables only load in the browser
The compatibility table in 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
Sets the browser theme to use a sun graphic with complementary background color:
const suntheme = {
images: {
theme_frame: 'sun.jpg',
},
colors: {
frame: '#CF723F',
tab_background_text: '#111',
}
};
browser.theme.update(suntheme);
Set the theme for just the currently focused window:
const day = {
images: {
theme_frame: 'sun.jpg',
},
colors: {
frame: '#CF723F',
tab_background_text: '#111',
}
};
browser.menus.create({
id: "set-theme",
title: "set theme",
contexts: ["all"]
});
async function updateThemeForCurrentWindow() {
let currentWindow = await browser.windows.getLastFocused();
browser.theme.update(currentWindow.id, day);
}
browser.menus.onClicked.addListener(updateThemeForCurrentWindow);
Example extensions
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论