简体   繁体   中英

Chrome extension to help study

I'm trying to write a chrome extension to help get myself back to work (and hopefully friends too). For now, the goal is when users go to Facebook, they're redirected to a webpage that I'll make which will have a message "get back to work".

I've managed as far as setting it up, just can't manage to find the js code to redirect.

manifest.json

{
  "manifest_version": 2,

  "name": "Get Back to Work",
  "description": "GET BACK TO WORK!",
  "version": "0.1",

  "content_scripts": [
    {
      "matches": [
        "*://facebook.com/*", "*://www.facebook.com/*"
      ],
      "js": ["content.js"]
    }
  ],

  "browser_action": {
    "default_icon": "icon.png"
  }
}

content.js:

alert("this works");
//code here

Any suggestions?

just set

Window.location = "http://getbacktowork.com";

inside your content.js

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