小编Vin*_*eni的帖子

资源必须列在web_accessible_resources清单键中,以便由扩展名外的页面加载

我已经尝试了很多方法(所有文档化的程序),在检查onUpdated.addListener上的URL时将脚本注入特定页面.最后,带有'executioncript'的下面代码似乎有效,但并不完美.我能够获取警报,但无法通过getElementById/getElementsByName查找页面的文档元素.

当我检查页面时,脚本被注入.但在错误控制台中,我得到:

拒绝加载chrome-extension://jfeiadiicafjpmaefageabnpamkapdhe/js/Leoscript.js.资源必须列在web_accessible_resources清单键中,以便由扩展名外的页面加载.

manifest.json的:

{
  "name": "Leo Extension for Job Boards",
  "version": "1.6",
  "manifest_version": 2,
  "content_security_policy": "script-src 'self'; object-src 'self'",
  "description": "Leo Extension",
  "background": {
    "scripts": ["js/Leojshelper.js"],
    "persistent": true
  },
  "content_scripts": [
    {
      "matches": ["<all_urls>"],
      "js": ["js/eventPage.js"],
      "run_at" : "document_start"
    }
  ],
  "icons":{"48":"images/bob48.png", "128":"images/bob128.png"}, //Define any icon sizes and the files that you want to use with them. 48/128 etc.
  "browser_action": {
    "default_icon": "images/bob.png",       // What icon do you want to display on the chrome toolbar
    "default_popup": "LeoExtwatch.html"     // The …
Run Code Online (Sandbox Code Playgroud)

google-chrome google-chrome-extension

25
推荐指数
3
解决办法
5万
查看次数

chrome.tabs.onUpdated.addListener为每个页面获得两次或更多的完整状态

这是我的脚本,它使用onUpdated.addListener来检查每个url:

chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {          
 alert(changeInfo.status);
 if (changeInfo.status == 'complete') {
 if (tab.url.indexOf("in.yahoo.mail") !== -1) {
 alert(tab.url);
 chrome.tabs.update(tabId, { url: "https://accounts.google.com/ServiceLogin" });
  //injectToTab(tab);
  }
 }
}); 
Run Code Online (Sandbox Code Playgroud)

这是清单代码:

 {
  "name": "LeoPlugin For Test",
  "version": "1.6",
  "manifest_version": 2,
  "content_security_policy": "script-src 'self'; object-src 'self'",
  "description": "Extension to Automate.",
  "background": {
    "scripts": ["js/eventPage.js"],
    "persistent": false
  },
  "content_scripts": [
    {
      "matches": ["http://*/*"],
      "js": ["js/eventPage.js"]
    }
  ],
  "icons":{"48":"images/bob48.png", "128":"images/bob128.png"}, //Define any icon sizes and the files that you want to use with them. 48/128 etc. …
Run Code Online (Sandbox Code Playgroud)

google-chrome google-chrome-extension

10
推荐指数
1
解决办法
1万
查看次数