create()

in src/services/ActionMenu.js [4:26]


  create(onCheckedChanged) {
    if (this.#created) {
      return;
    }

    this.#created = true;

    chrome.contextMenus.create({
      id: MENU_ITEM_ID,
      type: chrome.contextMenus.ItemType.CHECKBOX,
      title: DEFAULT_TITLE,
      enabled: false,
      checked: false,
      contexts: [chrome.contextMenus.ContextType.ACTION],
      documentUrlPatterns: ["http://*/*", "https://*/*"],
    });

    chrome.contextMenus.onClicked.addListener((info, tab) => {
      if (info.menuItemId === MENU_ITEM_ID) {
        onCheckedChanged(info.checked, tab.url);
      }
    });
  }