Chrome extension open new tab on new tab

前端 未结 2 1629
轻奢々
轻奢々 2020-12-04 02:18

I have created a Chrome extension that, as part of it\'s operation, opens a new tab with a specified url.

chrome.runtime.onMessage.addListener(
  function(r         


        
2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-04 03:02

    Well, this message is supposed to come from a content script you're trying to inject into the current tab.

    The widest permission you can request is "", however, there are still URLs that are excluded from access.

    1. You can only normally access http:, https:, file: and ftp: schemes.

    2. file: scheme requires the user to manually approve the access in chrome://extensions/:

    <code>file:</code> access

    1. Chrome Web Store URLs are specifically blacklisted from access for security reasons. There is no override.

    2. chrome:// URLs (also called WebUI) are excluded for security reasons. There is a manual override in the flags: chrome://flags/#extensions-on-chrome-urls, but you can never expect it to be there.

    3. There is an exception to the above, chrome://favicon/ URLs are accessible if you declare the exact permission.

    All in all, even with the widest permissions you cannot be sure you have access. Check for chrome.runtime.lastError in the callback of executeScript and fail gracefully.

提交回复
热议问题