0

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?

jordanc
  • 65
  • 5
  • 1
    I suggest you read the [Chrome extension overview](https://developer.chrome.com/extensions/overview) (perhaps along with the pages linked from the overview). The [architecture section](https://developer.chrome.com/extensions/overview#arch) has overall architecture information which should help your understanding of how things are generally organized/done. You will probably also want to read [Content Scripts](https://developer.chrome.com/extensions/content_scripts). – Makyen Mar 03 '17 at 08:19
  • [Why is “Can someone help me?” not an actual question?](http://meta.stackoverflow.com/q/284236) – Zig Mandel Mar 03 '17 at 12:46

1 Answers1

1

just set

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

inside your content.js

psycho
  • 102
  • 8
  • Got it. Now have a look [http://stackoverflow.com/questions/4859689/how-do-i-redirect-to-a-url-using-a-google-chrome-extension-content-script](http://stackoverflow.com/questions/4859689/how-do-i-redirect-to-a-url-using-a-google-chrome-extension-content-script) – psycho Mar 03 '17 at 07:50
  • found that page already - it's for a background page but I'm running a content script. again, not completely sure what the difference is but i can't get that code to work – jordanc Mar 03 '17 at 08:00