在URL更改时注入内容脚本

时间:2018-09-21 04:33:48

标签: javascript google-chrome-extension

我正在研究 chrome扩展 ,在其中我需要 在URL更改时注入内容脚本 。 (PS:出于安全原因,我无法显示该网址)

例如,我有页面:

首页https:abc.com/index#rating.html

第二页: https:abc/index#prerating/id=123

第三页: https:abc/index#activerating/id=345

现在,我首先进入URL 1,然后进入2,然后进入3。我想将其插入到第三页。注意:只有从URL 1、2,然后3(依次)导航后,才能访问URL 3。

有人可以帮忙吗?

manifest.json:

{
  "name": "Daca",
  "version": "1.0",
  "manifest_version": 2,
  "description": "Update spreadsheet on user Submit",
  "browser_action": {


  },

  "permissions": ["activeTab","tabs", "<I am puzzled what URL to use?>", "https://apis.google.com/js/client.js", "https://accounts.google.com/o/oauth2/token", "identity", "identity.email", "https://content-sheets.googleapis.com/v4/spreadsheets/*"],

  "content_scripts": [
  {
    "matches": ["<I am puzzled what URL to use?>"],
    "js": ["popup.js"],
    "run_at": "document_start"
  }
    ],
  "oauth2": {
    "client_id": "<my client id>",
    "scopes": [

        "https://www.googleapis.com/auth/spreadsheets"
    ]
    },
    "content_security_policy": "script-src 'self' 'unsafe-eval' https://apis.google.com; object-src 'self'"
}

popup.js:

 console.log("hey");

0 个答案:

没有答案