-
Notifications
You must be signed in to change notification settings - Fork 56
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: Allow globs for the contextMenus API instead of just URL patterns. #583
Comments
The example you've shown is the same as a match pattern. Match patterns are already sufficiently expressive to enable "contains" match, in the path or query component of a URL. Do you have a use case where a glob would work but a MatchPattern would not? Even without any new APIs, it is already possible for extensions to toggle the visibility of context menus, by calling Firefox has the Chrome does not support the If you are interested in exploring
|
I would like to provide a field where the user can provide a URL Here's a more accurate example of how I plan to use it. This would be an invalid URL pattern, but a valid glob. browser.contextMenus.create({
...,
documentUrlGlobs: [`*${containsKeyword}*`]
}) |
Your provided use case is already possible with match patterns: |
My bad. By URL fragment, I meant a substring within any part of the URL |
@Rob--W That assumes the extension has access to the URL, which is not always the case (especially in Safari). While Safari does not currently support globs for anything in Web Extensions, I would be supportive of this if we do add support for globs. |
Side note: I loathe the fact that the |
FWIW, enforcing camelCase when combining is a widely used convention, nothing criminal. |
What about |
I'd like to see use cases before expanding the API surface. The original use cases provided thus far can be covered with match patterns. It may be tempting to "relax" the syntax, by allowing a ln arbitrary glob instead of a "stricter" match pattern as documentUrlPatterns (and targetUrlPatterns), but that is not backwards-compatible. In a match pattern, Conceptually I am not opposed to expanding globs, but only if there are compelling use cases that need it. |
A contains-like pattern can be covered by match patterns, but it's more cumbersome and requires parsing the user's submitted keyword to generate an equivalent match pattern. Edit: On further thought, a contains-like pattern can't be fully covered because match patterns don't support partial hosts. The host has to be fully defined except for the subdomain. |
The previous discussions are all technical and developer-oriented. The real problem is that the author wants users to customize the rules. This means several questions:
If the target users understand technology (e.g. users are developers), you can use the existing |
@hanguokai Great points! For my case, the latter is the only option. If documentUrlGlobs was supported, I could just throw an input field with a label that says |
The contextMenus API allows for restricting a context menu item to pages that match a URL pattern. I propose also allowing for globs instead of only URL patterns. I wanted to allow users to customize where the context menu is shown, but came to realize that URL patterns makes it difficult to support a contains-like pattern.
The text was updated successfully, but these errors were encountered: