Content script on chrome error page

不问归期 提交于 2020-01-04 05:25:11

问题


How can I run my extension content script on Google Chrome error page?

For example on the "This webpage is not available" error page? Here is my manifest.json config:

{
  "manifest_version": 2,
  "name": "injectbox",
  "version": "1.1",
  "background": {
    "scripts": ["jquery-1.11.1.min.js", "bg.js" ]
  },
  "content_scripts": [  
    {
      "js": [ "jquery-1.11.1.min.js" ],
      "matches": [ "<all_urls>" ],
      "match_about_blank": true,
      "run_at": "document_end"
    },
    {
      "js": [ "content.js" ],
      "css":["styles.css"],
      "matches": [ "<all_urls>" ],
      "match_about_blank": true,
      "run_at": "document_end"
    }
  ],
  "permissions": [
    "tabs", "http://*/*", "https://*/*", "file://*/*", "ftp://*/*",
    "webRequest",
    "storage"
  ]
}

回答1:


I don't think it's possible, most probably this is an internal chrome:// page, which are excluded from page matches.

An alternative solution would be to listen to error events in webRequest/webNavigation APIs and replace the error page with your own.



来源:https://stackoverflow.com/questions/25502927/content-script-on-chrome-error-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!