-1

enter image description here

Hello all, I'm building a chrome extension that generates a quote, in response to a user's emotions.

My chrome extension involves the usage of a content-script that modifies the user's active browser window, by using DOM and JS to insert an overlay over the screen. The above picture shows this.

However, I noticed that my chrome extension doesn't work on chrome:// based URLs (example: chrome://extensions/ and chrome://newtab).

It throws the following exception:

Uncaught (in promise) Error: Could not establish connection. Receiving end does not exist.

It works everywhere else and doesn't throw this exception.

I saw that in a similar StackOverflow post, chrome extension do not work after execute extension in url chrome://, and through some research online, Google Chrome won't allow to run extensions whose behavior involves modifying chrome's settings and functionality.

Does this apply to my extension's case? Is there a way I can get around this? I have posted below my chrome extension's manifest.json file. Ideally I'd like my extension to at least be able to run on chrome://newtab . I would really appreciate insight on this matter.

manifest.json

{

  "manifest_version": 3,
  "name": "Quotr",
  "description": "A Quote Generator Chrome Extension",
  "version": "1.0",
  "permissions": [
    "tabs",
    "activeTab"
  ],
  "action": {
    "default_popup": "popup/popup.html",
    "default_icon": "icons/QuotrPicture.png"
  },
  "content_scripts": [
    {
      "matches": [
        "<all_urls>"
      ],
      "js": [
        "scripts/content-script.js",
        "quote-display/quote-display.js"
      ]
    }
  ]
}

  • Because chrome:// locations are URIs, not URLs. They're browser-internals, not web locations, as you can readily tell from the fact that their protocol isn't http(s). – Mike 'Pomax' Kamermans Jul 23 '23 at 19:34

1 Answers1

1

Content scripts are not allowed on any chrome:// pages newtab included. https://codereview.chromium.org/2978953002/.

From the same source:

Extensions wishing to modify the New Tab Page should do so through the use of the chrome url overrides [1] API

So I guess the closest workaround would be to create a custom newtab landing page (there're extensions out there that do this) and allow your script to run there.

b00t
  • 409
  • 3
  • 10