How can I reload my chrome extension by javascript?

后端 未结 2 1321
醉话见心
醉话见心 2021-01-25 03:16

I\'m trying to make that if you press a button in the popup window in my chrome extension, it will reload the extension. Is that possible?

相关标签:
2条回答
  • 2021-01-25 03:40

    Just found this method, which does exactly what I want:

    chrome.runtime.reload();
    
    0 讨论(0)
  • 2021-01-25 03:51

    Add this code to manifest.json:

    "background": {
      "persistent": false,
      "scripts": [ "background.js" ]
    }
    

    Add this code to background.js:

    chrome.browserAction.onClicked.addListener(function(tab) {
      chrome.runtime.reload();
    });
    
    0 讨论(0)
提交回复
热议问题