简体   繁体   English

Chrome扩展程序可帮助学习

[英]Chrome extension to help study

I'm trying to write a chrome extension to help get myself back to work (and hopefully friends too). 我正在尝试编写一个Chrome扩展程序,以帮助自己恢复工作(希望也能成为朋友)。 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". 目前,目标是当用户访问Facebook时,他们将被重定向到我将创建的网页,该网页将显示一条消息“恢复工作”。

I've managed as far as setting it up, just can't manage to find the js code to redirect. 我已经尽力进行设置,只是无法找到要重定向的js代码。

manifest.json 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: content.js:

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

Any suggestions? 有什么建议么?

just set 刚设置

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

inside your content.js 在您的content.js中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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