What is the URL of the google chrome new tab page and how to exclude it from manifest.json

后端 未结 4 863
不思量自难忘°
不思量自难忘° 2020-12-03 19:23

I am currently building a simple google chrome extension to prank my brother. The Extension simply deletes the old page and replaces it with HTML and CSS copied off of the \

相关标签:
4条回答
  • 2020-12-03 20:01

    Please note that most of the content in my original answer from 2016 no longer holds true.

    • As of Chrome v61, content scripts are no longer allowed on the New Tab Page.

    • The URL of the new tab page has changed to chrome-search://local-ntp/local-ntp.html.

    • If you want to create a custom New Tab Page, use override pages.

    I decided to delete the original content of this answer to avoid possibly misleading somebody. The original answer can be viewed in edit history.

    0 讨论(0)
  • 2020-12-03 20:03

    Opened a new tab, opened the Dev Tools - Network tab. Looks like it requests https://www.google.com/_/chrome/newtab. Try with this one, maybe.

    0 讨论(0)
  • 2020-12-03 20:18

    It's probably safer to use "exclude_globs" instead of "exclude_matches". With "exclude_matches": ["*://*/_/chrome/newtab*"] you could unintentionally skip something like http://example.com/_/chrome/newtab:

    "content_scripts": [{
        "matches": ["<all_urls>"],
        "exclude_globs": ["https://www.google.*/_/chrome/newtab*"],
        "run_at": "document_end",
        "js": ["script.js"]
    }],
    
    0 讨论(0)
  • 2020-12-03 20:22

    According to Match Patterns, chrome is not a valid scheme.

    scheme := '*' | 'http' | 'https' | 'file' | 'ftp'

    1. You could use the following exclude_matches

      "exclude_matches": ["*://*/_/chrome/newtab*"]
      
    2. You could also check if window.location.href contains chrome/newtab in you content scripts.

    0 讨论(0)
提交回复
热议问题