返回
true
if the browser action is enabled.
This is an asynchronous function that returns a
Promise
.
let gettingIsEnabled = browser.browserAction.isEnabled(
details
// object
)
details
对象
. An object optionally containing the
tabId
or
windowId
to check.
tabId
可选
integer
. ID of a tab to check.
windowId
可选
integer
. ID of a window to check.
A
Promise
that will be fulfilled with
true
if the extension's browser action is enabled, and
false
否则。
BCD tables only load in the browser
Check the global state:
browser.browserAction.isEnabled({}).then(result => {
console.log(result);
});
Check the state of the currently active tab:
async function enabledInActiveTab() {
let tabs = await browser.tabs.query({
currentWindow:true,
active: true
});
let enabled = await browser.browserAction.isEnabled({
tabId: tabs[0].id
});
console.log(enabled);
}
最后修改: , 由 MDN 贡献者