-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Add excludeTopFrameMatches and excludeTopFrameGlobs. #763
Comments
Related issue: #668 |
Chromium bug: https://issues.chromium.org/issues/40202338 |
Another related issue #117. |
@Rob--W My concerns with the
|
Furthermore, as @gorhill already pointed out in #668 (comment), how would static document_start main world scripts know what to compare We're asking for a simple API that does what we want, without requiring each and every developer to implement hacks or unnecessary/bug prone custom matching logic. |
@ghostwords Not sure about that context, but In my use case, it can be used to disable the extension based on the top frame's origin. E.g. the user adds reddit.com to a list of websites they want disabled, the extension checks |
To reiterate what I said in the last public meeting, I'm personally (not speaking on behalf of Chrome) supportive of this request. We would want to restrict matching to be based on the origin (or we could use a match pattern with a forced-wildcard path). Matching based on an actual path is much harder from a technical perspective. There is already a lot of precedence for a "disable this site" option in the extension ecosystem, so I don't feel as strongly that we need to prove the demand for this. In parallel, I do also like @Rob--W's suggestion in #668 to solve this with content script params. It wouldn't avoid injecting a content script entirely, so there is still value in this request, but it definitely seems like it would be an improvement and would be worth pursuing in parallel. I know that proposal hasn't moved anywhere in a long time, but chatting with Rob recently I think we are both keen to see if we can get it some momentum again. |
Many extensions offer, or would like to offer, users the ability to blocklist the extension on certain websites. But currently, the typical method of implementing that is by using a dynamic content script and adding the blocked sites to
excludeMatches
, but this results in behavior that doesn't align with user expectations.When a user blocks a site like Reddit, they expect the extension to be completely disabled when they visit Reddit. However, with the current
excludeMatches
approach: the content script still runs on Reddit if an embedded frame loads content from a different domain. Conversely, if a user visits another website that embeds Reddit content (e.g., a news site displaying a Reddit thread), the extension is blocked from running within that embedded Reddit frame, even if the user did not intend to block it there.Proposal
scripting.registerContentScripts()
should acceptexcludeTopFrameMatches
andexcludeTopFrameGlobs
. If provided, it will exclude based on the top frame's URL.This allows extensions to, more easily, implement a blocklist system that's user intuitive.
First proposed by @kzar : https://issues.chromium.org/issues/40202338
Thanks @ghostwords for pointing it out.
Current workarounds
Let the content script load and then check the top frame URL (e.g.
Location.ancestorOrigins
) to decide whether it should run. However, this is inefficient since the script still loads, using memory and resources even when it doesn’t execute.The text was updated successfully, but these errors were encountered: