Run script each time Chrome extension icon clicked

前端 未结 5 1209
有刺的猬
有刺的猬 2020-12-02 06:44

How do I write a chrome extension such that every time a user clicks the icon, my script is run but no popup is opened? (I would look this up in the docs myself but for wha

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-02 07:01

    This was just what I needed but I should add this: If all you need is a one-time event like when a user clicks on the extension's icon, then Background Pages is a waste of resources as it will run in the background ALL the time. Use Event Pages instead:

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

提交回复
热议问题