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

Reconsider implementing GM_registerMenuCommand in GM 4.x #2714

Closed
darkred opened this issue Nov 20, 2017 · 7 comments
Closed

Reconsider implementing GM_registerMenuCommand in GM 4.x #2714

darkred opened this issue Nov 20, 2017 · 7 comments

Comments

@darkred
Copy link

darkred commented Nov 20, 2017

As I saw (see comment) GM_registerMenuCommand is replaced with HTML5 context menu. and there's no plan to add it in GM 4.x.

Nevertheless, I've started this separate issue. in hope that you'll might reconsider.


I understand that adding some context menu options in the native context menu,
is useful for those that do want to add more entries in that.
Such as this new test script by arantius search-with-google.
screenshots:
2017-11-20_171908 2017-11-20_172014


But, for userscripts that use GM_registerMenuCommand only for settings, i.e. you only configure then only once in a while.
and apply to all pages,
such as the popular:
Mouseover Popup Image Viewer, (settings screenshot)
YouTube Link Title (settings screenshot) and
Linkify Plus Plus (settings screenshot )

Imagine having installed these scripts that create a total of 3 entries on top of the context menu
that are not needed most of the time:
it would make use the context menu on the page cluttered and unpractical.

And then the script author, in order to avoid cluttering the context menu just for the sake for offering settings,
he would either register a keyboard shortcut on every page (with no UI?)
or create a new dedicated button element on every page.


So, I'd like to ask you please to reconsider implementing GM_registerMenuCommand inside the toolbar button popup, similar to how it was in GM 3.x, as well as in the other most used scripts managers available, Tampermonkey and Violentmonkey.
,
It would appear between/below the "Greasemonkey is active/disabled" entry,
and above the 'User scripts for this tab' list (GM 4.1 beta4).

@darkred
Copy link
Author

darkred commented Nov 20, 2017

For reference, I quote the relevant discussion from #2559 :


(eight04)

arantius I saw that GM_registerMenuCommand is replaced with HTML5 context menu. Is there any plan to add it in GM 4.x? I can't find the tracking issue.

(arantius)

No. Greasemonkey's policy has been (for a long time) not to implement "user space" features. Any script can do this, or @require something like this polyfill which does it. Greasemonkey doesn't need to build nor support this feature to enable scripts to use it. The point here is just to do what the polyfill does: make it easier to update scripts to be compatible with both old and new versions of Greasemonkey.

(eight04)

I meant if GM4 will also provide an API to execute script commands from the UI of userscript manager like old GM_registerMenuCommand, not asking whether there will be a HTML5 contextmenu API in GM. GM_registerMenuCommand is often used to launch script configuration dialog, which shouldn't be polyfilled as a HTML5 contextmenu IMHO.

BTW, I have created a library to work with HTML contextmenu just few months ago, which would reuse contextmenu property on the page if it is already set:
https://github.com/eight04/GM_context

(arantius)

GM_registerMenuCommand is often used to launch script configuration dialog, which shouldn't be polyfilled as a HTML5 contextmenu IMHO

Why not?

(eight04)

Why not?

1. The command on the contextmenu should be:

- An action which works on specified context (element). For example, when some text is selected, "Copy" command, which is an action to work with the selection, is shown.
- A shortcut to execute specified command for convenience.
A "My userscript setting" command doesn't fall into both categories. It does not depend on the context, also there is no need to use a shortcut for configuration.

2, It is not reliable. It may be blocked/replaced by page scripts.

(trlkly)

I agree with the conceptual level difficulties. I do not have any extensions anymore that use the context menu for settings. It would get pretty busy pretty quickly if they did, since I run a lot of extensions.

But the main reason I see is that Chrome has removed the HTML5 context menu from the spec, which means it's probably going to be removed from Firefox, too. I didn't even know it existed, seeing as I've not seen any site use it. Apps just spin their own, blocking the real context menu (which is a huge, huge annoyance in most cases. That removes functionality.)

@Sxderp
Copy link
Contributor

Sxderp commented Nov 20, 2017

This gives me a headache trying to think about how the scripts would interact. Assuming there was a menu option and said menu option opened some sort of window / box / dialog / whatever to change settings, is that newly generated window considered to be in the 'content script' context and therefore able to send messages to the extension? And if it's not then how does one send a message back to the content script, so that settings can be changed?


Though, it seems that a common theme is settings menus. I'd be in favor of having staticly defined configuration fields in the metablock that are then generated and can be saved / modified through the Monkey menu. Similar to a resource but are changed by going Monkey Menu -> Script -> Config -> Items.

@darkred
Copy link
Author

darkred commented Nov 20, 2017

I'd be in favor of having staticly defined configuration fields in the metablock that are then generated and can be saved / modified through the Monkey menu. Similar to a resource but are changed by going Monkey Menu -> Script -> Config -> Items.

I'm afraid that using static configuration fields in the metablock would make it too limiting:
for example, for the 1st mentioned script Mouseover Popup Image Viewer,
apart from the current practical layout(dropdown menus, checkboxes, textboxes with scrollbar, textarea),
the settings menu currently offers:

  • import/export the settings (to clipboard),
  • install rules from the MPIV repository right inside the settings,
  • there's find-as-you-type rules when there are a lot of custom host rules installed,
  • it validates whether the entered custom host rule is valid JSON, and highlights the input row red if not,

Plus, its author should have to rewrite the entire 'setup code.

settings screenshot

@arantius arantius added this to the Pony milestone Nov 21, 2017
@legnaleurc
Copy link

FWIW, W3C removed context menu from HTML5, and Firefox is going to remove it as well.

@Cerberus-tm
Copy link

@legnaleurc Gosh, that could be an issue for some people. As a total layman, I have no idea, but do you happen to know of an alternative way to add context menu items, to replace the method that uses

? Is there some simple method I am not aware of that's usable from a userscript?

esperecyan added a commit to esperecyan/greasemonkey that referenced this issue Dec 14, 2017
esperecyan added a commit to esperecyan/greasemonkey that referenced this issue Dec 15, 2017
esperecyan added a commit to esperecyan/greasemonkey that referenced this issue Jan 6, 2018
esperecyan added a commit to esperecyan/greasemonkey that referenced this issue Jan 7, 2018
esperecyan added a commit to esperecyan/greasemonkey that referenced this issue Jan 7, 2018
esperecyan added a commit to esperecyan/greasemonkey that referenced this issue Jan 10, 2018
esperecyan added a commit to esperecyan/greasemonkey that referenced this issue Jan 10, 2018
esperecyan added a commit to esperecyan/greasemonkey that referenced this issue Jan 20, 2018
esperecyan added a commit to esperecyan/greasemonkey that referenced this issue Jan 20, 2018
esperecyan added a commit to esperecyan/greasemonkey that referenced this issue Jan 27, 2018
esperecyan added a commit to esperecyan/greasemonkey that referenced this issue Jan 30, 2018
esperecyan added a commit to esperecyan/greasemonkey that referenced this issue Feb 10, 2018
esperecyan added a commit to esperecyan/greasemonkey that referenced this issue Mar 4, 2018
esperecyan added a commit to esperecyan/greasemonkey that referenced this issue Mar 4, 2018
esperecyan added a commit to esperecyan/greasemonkey that referenced this issue Mar 4, 2018
esperecyan added a commit to esperecyan/greasemonkey that referenced this issue Jan 10, 2021
esperecyan added a commit to esperecyan/greasemonkey that referenced this issue Jan 11, 2021
@arantius
Copy link
Collaborator

Done in #3078

@arantius arantius removed this from the Pony milestone Jan 28, 2021
@darkred
Copy link
Author

darkred commented Jan 28, 2021

Thank you.

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

No branches or pull requests

5 participants