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

GM_registerMenuCommand - errors vs. invalid link, frames; GM_getResourceURL - no resource with name #2434

Closed
wants to merge 2,295 commits into from

Conversation

janekptacijarabaci
Copy link
Contributor

@janekptacijarabaci janekptacijarabaci commented Sep 30, 2016

1)

GM_registerMenuCommand

For example:

// ==UserScript==
// @name        Greasemonkey - GM_registerMenuCommand
// @include     https://github.com/
// @grant       GM_registerMenuCommand
// ==/UserScript==

GM_registerMenuCommand("Command1");
GM_registerMenuCommand("Command2", "is not a function");
GM_registerMenuCommand("Command3", function () {}, "accesskey");

Firefox throws an errors in the Error Console:
error

The link leads to a meaningless line in source file.

I propose to add a translation.

2)

GM_getResourceURL

// ==UserScript==
// @name        Greasemonkey - GM_getResourceURL
// @include     https://github.com/
// @grant       GM_getResourceURL
// ==/UserScript==

GM_getResourceURL("nothing");

The "No resource with name" - this does not work.

3)

GM_registerMenuCommand

Ad #2509

Frames - it won't add any menu commands.


The suggestion (for example).

It is necessary to test all options!

arantius and others added 30 commits May 29, 2015 09:29
Content can see resource: but not chrome: URLs.  And chrome: works fine for JSM import.

Fixes greasemonkey#1787
Start much smaller, allow the user to change the size, remember the size.

Fixes greasemonkey#2191
1) Store menu commmands' data in a private closure, *in the sandbox*.
2) To list registered commands:
  a) Parent/chrome passes a message to child/frame.
  b) Frame passes an event (visible to content) into the sandbox.
  c) Sandbox passes private-closure-scoped commands' data to a frame-scoped callback.
  d) Frame passes data up to parent as a message.
  e) Chrome uses this data to populate the menu, at popupshowing time.
3) To run a command:
  a) User clicks on the menu item.
  b) Chrome sends a message to the frame.
  c) Frame sends an event to the sandbox.
  d) Sandbox finds the related registered command, calls its callback.

Phew!  But no references to documents/windows/browsers are ever stored anywhere, so they can't possibly leak anymore.

Along the way, simplify frame script by moving object methods to standalone functions; less state, less binding to fix "this" references.  The ContentObserver object is now really just there for `.observe()`.

TODO: Restore "delayed execution" feature, the only other usage of the (removed) ScriptRunner structure.

Refs: greasemonkey#2200
Refs: greasemonkey#2067
Just in case, so the command object cannot be changed.
Prevent event propagation when appropriate.  Add a random suffix to the event names, so content cannot predict the event name, and thus cannot listen for it.
I.e. from an old Sync record which did not specify user matches.  Default to nothing.

Fixes greasemonkey#2188
It's too late.  IDs are set.  Changing them would be a giant mess.
@arantius arantius added this to the 3.10 milestone Sep 30, 2016
@arantius arantius modified the milestones: 3.10, 3.11 Feb 22, 2017
@arantius arantius modified the milestones: 3.11, 3.12 Mar 13, 2017
@janekptacijarabaci janekptacijarabaci changed the title GM_registerMenuCommand - errors vs. invalid link; GM_getResourceURL - no resource with name GM_registerMenuCommand - errors vs. invalid link; GM_getResourceURL - no resource with name; GM_registerMenuCommand - frames May 24, 2017
@janekptacijarabaci janekptacijarabaci changed the title GM_registerMenuCommand - errors vs. invalid link; GM_getResourceURL - no resource with name; GM_registerMenuCommand - frames GM_registerMenuCommand - errors vs. invalid link, frames; GM_getResourceURL - no resource with name May 24, 2017
@arantius arantius removed this from the 3.12 milestone Aug 16, 2017
@arantius arantius closed this Aug 16, 2017
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

Successfully merging this pull request may close these issues.

None yet

7 participants