简体   繁体   中英

Disable chrome extension

i am creating an chorme extension in which extension will change the color of facebook. i have added a button and i only want it to make facebook black whenever it is clicked. i have already created the button with on click property. how can i disable my app by clicking on it? here is my code

popup.html

  </head>
  <body>

<button onclick="myFunction()">Click Me</button>


  </body>
</html>

code.js

function myFunction() {
    //what should i write here?//
}

menifest.json

{
   "browser_action": {
      "default_icon": "icon.png",
      "default_popup": "popup.html",
      "default_title": "Black Facebook"
   },
   "content_scripts": [ {
      "css": [ "facebook-bw.css" ],
      "matches": [ "https://www.facebook.com/*" ]
   } ],
   "description": "Black Theme has been activated",

   "manifest_version": 2,
   "name": "Black Facebook",
   "version": "0.1.0"
}

You should be able to declare your script as a background script in the manifest.json file and in the script have a listener like:

chrome.browserAction.onClicked.addListener(function(tab) {
   chrome.tabs.executeScript(null, {file: "script.js"});
});

And that script.js would handle parsing the page and changing colors (I did something similar except was parsing the text on the page with a regex to look for key words.

Here's a good reference: Run script each time Chrome extension icon clicked

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM