'How disable chrome extension from popup menu?

i create my extension and i want create disable/enable button to popup menu in my chrome extension

i has created popup.html file

 <button id="disable">Disable</button>

and i has created popup.js file

 function disable_ext()
    {
      console.log ('111');
    }
    document.querySelector('#disable').addEventListener('click', disable_ext);

if simply open in browser popup.html file and press disable button then in console i see "111" result, but if open popup.html in menu (click in icon of extension left button of mouse) and has been press disable button then there is no result in the console "111"

How correct create event from button to disable chrome extension?



Solution 1:[1]

answer to this question

popup.html

<button id="disable">Disable</button>

popup.js

function disable_ext()
{
  var id = chrome.runtime.id;
  chrome.management.get(id, function(ex)
    {
        if(ex.enabled)
          {
            chrome.management.setEnabled(id, false);
          }
    });
}

document.querySelector('#disable').addEventListener('click', disable_ext);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1