Chrome content script does not load in about:blank page

后端 未结 2 659
小鲜肉
小鲜肉 2021-01-19 01:24

I am developing a Chrome extension which will load content script according to the following manifest:

\"content_scripts\" : [
    {
      \"matches\" : [ \"         


        
相关标签:
2条回答
  • 2021-01-19 01:50

    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().

    0 讨论(0)
  • 2021-01-19 02:04

    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
     }
    ]
    
    0 讨论(0)
提交回复
热议问题