Chrome content script does not load in about:blank page

霸气de小男生 提交于 2019-12-01 18:24:08
Brock Adams

Update: As of Chrome 37 (August 26, 2014), you can set the match_about_blank flagDoc to true to fire for about:blank pages.

See alib_15's answer below.



For Chrome prior to version 37:

You cannot load a Chrome content script (or userscript) on about:blank pages.

This is because about: is not one of the "permitted schemes". From chrome extensions Match Patterns:

A match pattern is essentially a URL that begins with a permitted scheme (http, https, file, ftp, or chrome-extension)...


In this case, you might be better off hijacking makewindow().

In the manifest file, add a line:

"content_scripts" : [
{
  "matches" : [ "<all_urls>" ],
  "match_about_blank" : true,
  "js" : [  "scripts/namespace/namespace.js",
            "scripts/log/Logger.js"]
   "run_at" : "document_start",
   "all_frames" : true
 }
]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!