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

Deprecate @include and @exclude metadata #650

Open
ACTCD opened this issue May 1, 2024 · 11 comments
Open

Deprecate @include and @exclude metadata #650

ACTCD opened this issue May 1, 2024 · 11 comments
Labels
deprecate Breaking changes
Milestone

Comments

@ACTCD
Copy link
Collaborator

ACTCD commented May 1, 2024

We will deprecate @include and @exclude and only support @match and @exclude-match in the future.

We plan to add a deprecation hint in v5 and eventually remove it in v6.0.

@ACTCD ACTCD modified the milestones: v6.0.0, v5.0.0 May 1, 2024
@ACTCD ACTCD added the enhancement Feature work label May 1, 2024
@ACTCD ACTCD added deprecate Breaking changes and removed enhancement Feature work labels Jul 8, 2024
@F9y4ng
Copy link

F9y4ng commented Jul 18, 2024

Hi @ACTCD , Google search engine has hundreds of national domain names, use @include *://*.Google.* can match all national domain names, But, how to achieve wildcard through @match?

@ACTCD
Copy link
Collaborator Author

ACTCD commented Jul 18, 2024

Hi @F9y4ng, The @include *://*.Google.* will also match:

https://example.com/1.google.html
https://example.com/?site=www.google.com
https://1.google.example.com/
...

Obviously these are not your intentions, and may cause all kinds of damage.

That's why we want to make the change, to encourage developers to make more secure and accurate user scripts.

For your question, here is a userscript for Google, you can refer to its implementation: ACT.Google.DM.NCR.user.js

Hope this explains your question and satisfies you. Stay safe! :)

@F9y4ng
Copy link

F9y4ng commented Jul 18, 2024

Maybe I have to adopt your scheme after the browser forces to MV3. 😅

Thanks for your reply.

@jesus2099
Copy link

jesus2099 commented Jan 30, 2025

IMO, you should keep supporting include.
Match is very nice and better than include for simple things but it does not support regular expressions.

And many existing userscripts will not run on your extension.

@ACTCD
Copy link
Collaborator Author

ACTCD commented Jan 31, 2025

@jesus2099 Thank you for your opinion.

I think I have made it clear in OP.

If it retains it means additional complexity, maintenance, delay, and safety risks, I think it is reasonable to deprecate it.

For regular expression, I recommend using it in user scripts, for example: 249#issuecomment-1150674097

I always think:

  • The project should be refined and easier to maintain
  • Safety first, not external compatibility
  • Users deserve higher quality user scripts

So far I have not seen the reason for favorable reasons to change this, but I remain open.

@ACTCD
Copy link
Collaborator Author

ACTCD commented Jan 31, 2025

And many existing userscripts will not run on your extension.

For this point, I would like to explain my view additionally.

We have a reasonable deprecation cycle and this is not a change with a significant burden for any user script developer/author.

It takes very little time and effort to migrate, and comes with significant security and/or other benefits.

For those long term, unmaintained user scripts, I'm curious if they really still work properly on their own?

A user script is not a standalone program, it almost always works with the structure of the site's pages at a particular stage, and typically modern sites change their structure so often that if they aren't maintained and adapted in a timely manner, they will usually fail to work correctly very shortly.

And is it really worth carrying the burden and cost of these obsolete user scripts that may not work properly anyway?

@jesus2099
Copy link

I discovered this extension by random. I didn't know there was an iOS userscript extension! It's great for those iPhone users, at last!

But match sometimes takes more lines and is less strict than regex include.

It was my reasons to migrate this userscript from matches to regex include.

But as userscript author I don't always know that this or that userscript extensions supports everything in GM metadata and API standard, or not.

@ACTCD
Copy link
Collaborator Author

ACTCD commented Jan 31, 2025

@jesus2099 More lines != bad.

If needed, please use @match on more lines than the more error-prone regex.

The WebExtension API never supported "regex", it needs to be supported separately with complex logic.
And there are the same issues when switching to UserScripts API in the future.

But as userscript author I don't always know that this or that userscript extensions supports everything in GM metadata and API standard, or not.

Then, please read their documents.

@ACTCD
Copy link
Collaborator Author

ACTCD commented Jan 31, 2025

I need to emphasize again that this will not prevent you from using the Regex. The difference is that you only need to implement yourself in the user script, rather than we support it at the Extension level.

We want to make thin packaging of Web Extension API, and adopt and promote better security and less errors.

@jesus2099 If you want, you could even @match *://*/* and then use just ONE extra-long line of regex in your user script, no problem and works with almost any user script manager.

But what's the point?

Comparing lines doesn't make any sense, and not everyone is a regular expression expert.

We want better readability and less chance of error, which is why the Web Extension API created and recommends the use of Match patterns, and we hope to accurately convey that.

@jesus2099
Copy link

jesus2099 commented Jan 31, 2025

Yes yes, I see. 😁

I think you should display an error when one tries to install an include based userscript, once it's no longer supported.

So that people understand that they should request a new version from the author.

And same when an auto-update brings a version that introduces an include.

@ACTCD
Copy link
Collaborator Author

ACTCD commented Jan 31, 2025

I think you should display an error when one tries to install an include based userscript, once it's no longer supported.

We will warn about all metadata that will be deprecated or unsupported in the next major release, this is a work in progress.

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

No branches or pull requests

4 participants
@jesus2099 @F9y4ng @ACTCD and others