Can content script be run in another chrome extension?

86 views
Skip to first unread message

İbrahim Sarıkaya

unread,
Sep 24, 2022, 6:38:07 AM9/24/22
to Chromium Extensions
For example in the browser tab there is such a url:
chrome-extension://extensionID/home.html
Can I script content from a different chrome extension to the other extension on this tab?
In fact, such a question has been asked before, but it has been said that it cannot be done, is this a definite information?
https://stackoverflow.com/questions/71558475/execute-script-in-chrome-extension-page

wOxxOm

unread,
Sep 24, 2022, 10:46:52 AM9/24/22
to Chromium Extensions, kod...@gmail.com
You can use chrome.debugger API to attach to the extension and send commands like Page.addScriptToEvaluateOnLoad or Runtime.runScript or Runtime.evaluate. There will be a warning above all tabs in the browser when the extension uses chrome.debugger API, but you can hide it by running Chrome with  --silent-debugger-extension-api command line switch, just make sure to review all extensions you install/update if they have a debugger permission.

İbrahim Sarıkaya

unread,
Sep 25, 2022, 5:04:58 AM9/25/22
to Chromium Extensions, wOxxOm
Thanks for your reply, I'll look into the apis you mentioned.

24 Eylül 2022 Cumartesi tarihinde saat 17:46:52 UTC+3 itibarıyla wOxxOm şunları yazdı:

Simeon Vincent

unread,
Sep 26, 2022, 4:01:36 PM9/26/22
to İbrahim Sarıkaya, Chromium Extensions, wOxxOm
To directly address your question, no, content scripts cannot be used on extension pages. While it is technically possible to inject scripts in an extension page, this uses a different mechanism that is not, strictly speaking, the same as the content script system.

Assuming you're planning to publish your extension to the Chrome Web Store, there are some very important caveats to what wOxxOm shared.

First, features like content scripts do not interact with other extensions. This limitation is an intentional aspect of the platform.

Second, the API use section of the Chrome Web Store Developer Program Policies states that "Extensions must use existing Chrome APIs for their designated use case." 

Third, the Debugger API should not be used as a way of working around platform limitations. If your extension's single-purpose is not directly related to debugging websites or extensions, you probably shouldn't be using this API.

Fourth, disabling the debugger banner using the command line flag as suggested is very dangerous. Please, do not suggest that end users use this flag. 

Simeon - @dotproto
Chrome Extensions DevRel 

--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/1a439220-1d71-4dd9-bdbe-9b66065ac48fn%40chromium.org.

wOxxOm

unread,
Sep 27, 2022, 4:31:23 AM9/27/22
to Chromium Extensions, Simeon Vincent, Chromium Extensions, wOxxOm, kod...@gmail.com
>  Fourth, disabling the debugger banner using the command line flag as suggested is very dangerous. Please, do not suggest that end users use this flag.

A millions times less dangerous than the impending disaster of a half-broken half-made ManifestV3 being the only extension platform in 4 months. On a serious note though I agree and usually I emphasize the danger.

That said, it is actually possible to use the debugger permission with the silent flag in a safe manner by disabling this permission by default for all extensions except the ones you trust with your life. Unfortunately, configuring it is inconvenient or nigh impossible for an average user as it requires setting up a local policy, which frighteningly takes more than a couple of clicks. Note that it can be done by anyone on their personal computer not just the domain administrators. Ideally the browser should have a UI for this policy in advanced settings.
Reply all
Reply to author
Forward
0 new messages