Skip to content
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

[Feature Request / Question] Constraining overgreedy user styles to specific sites #1892

Open
Athari opened this issue Jan 17, 2025 · 3 comments

Comments

@Athari
Copy link

Athari commented Jan 17, 2025

Problem

I see no way to constrain global/overgreedy user styles to specific sites.

  1. The "Custom included sites" option seems to disable the author's matches completely and put all sections on the matched sites. There's no constraining "whitelist" option.
  2. The "Custom excluded sites" option allows disabling a style for specific sites, but the syntax seems to be limited to globs (iiuc), so I can't use this option to blacklist everything except the sites I need (I'd need negative lookaheads for that).

Real example

Case in point: Dark-Greasyfork. It has two @document sections: one useful, one global. Naturally, I don't want the global section to be used anywhere, especially considering it contains a :has() selector. However, I can't find a way to achieve that, like I'd do for, say, user scripts in Tampermonkey.

Possible solutions

If there's currently no way to constrain a global style, I can suggest adding these features:

  1. An "Enable author's matches" checkbox next to the "Custom included sites" list (checked by default). This way, it could be used as an actual whitelist.
    This is similar to Tampermonkey's "Original includes/excludes" checkboxes in a script's settings.

  2. Support for the full @document syntax in the "Custom included/excluded sites" lists, in addition to globs. This way, it would be possible to add something like regexp(...) for full control.
    This is similar to Tampermonkey's "User includes/excludes" lists in a script's settings, which use the same syntax as author's includes and excludes.

Both features seem straightforward to implement and will substantially improve the functionality of include and exclude lists, I think (considering this design is well tested in Tampermonkey and Violentmonkey.)

@tophf
Copy link
Member

tophf commented Jan 17, 2025

It's not really straightforward because the author of the styles can change the number of sections or their order, but indeed this would be more useful than wholesale inclusion. Initially I envisioned the same approach you described, IIRC, but since I'm lazy I never got to implementing it properly and others implemented it in a simplified form that only suits one-section styles.

@Athari
Copy link
Author

Athari commented Jan 17, 2025

@tophf
I do understand that dealing with adjusting the matching rules of every section individually would be a pain in the ass, and I'm not even sure it can be done in a satisfactory way for more complex styles.

What I'm suggesting is still treating the style as a single section but adding more flexibility to it. And if somebody ever decides to take up the challenge of dealing with individual sections, this improvement would still be a step in the right direction.

@mjsir911
Copy link

This patch should be helpful although I'm still trying to figure out how to self sign extensions for usage.

Basically just prioritize matching includes over excludes. is not backwards compatible.

include-exclude.patch.gz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants