browserAction.disable()

タブに対してブラウザアクションを無効にします。つまり、タブがアクティブな時クリックされなくなります。

書式

js

browser.browserAction.disable(
  tabId, // optional integer
);

パラメータ

tabId省略可

integer. ブラウザアクションを無効にしたいタブの ID です。

ブラウザーの互換性

BCD tables only load in the browser

クリックされたときブラウザアクションを無効にし、新しいタブが開かれる毎回再度有効にします:

js

browser.tabs.onCreated.addListener(() => {
  browser.browserAction.enable();
});

browser.browserAction.onClicked.addListener(() => {
  browser.browserAction.disable();
});

アクティブなタブにだけブラウザアクションを無効にします:

js

browser.browserAction.onClicked.addListener((tab) => {
  browser.browserAction.disable(tab.id);
});

メモ: This API is based on Chromium's chrome.browserAction API. This documentation is derived from browser_action.json in the Chromium code.Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.