Dear Johna, I have to ask if I understood your words correctly and
hopefully this short summary will also help others in case I got it right:
You are asking for a mode that makes GM run the scripts
A) outside the sandbox
B) without access to any of the GM_* API functions
GM could then deal with scripts that work exactly as if they were
located in the original source code of that web page. In this mode
scripts would not have and need any security model (as the API funtions
are "out of reach") like the wrappers, which would allow the scripts to
use JavaScript like you're used to from your usual web page coding.
You're suggesting to make GM treat all scripts like that in that mode,
as long as the script source [or any of the @include scripts, addition
by me] does not contain any of those API functions.
Did I get your idea right?
Chris
You are asking for a mode that makes GM run the scripts
A) outside the sandbox
B) without access to any of the GM_* API functions
GM could then deal with scripts that work exactly as if they were located in the original source code of that web page. In this mode scripts would not have and need any security model (as the API funtions are "out of reach") like the wrappers, which would allow the scripts to use JavaScript like you're used to from your usual web page coding.
You're suggesting to make GM treat all scripts like that in that mode, as long as the script source [or any of the @include scripts, addition by me] does not contain any of those API functions.
Okay, great! I can say I didn't like the idea when I read it, but after
I had my thoughts about it (because I had to think how to write that
abstract) I can say I totally love it (hah, that's how opinions change:
thinking about the subject!)
I wrote quite a few scripts, too, and most of them are enhancing
websites by some small stuff like additional links, changed element
order or something else that doesn't need the GM-APIs. Concerning all of
my scripts - far more than 100 - I think I'm using the API functions
maybe in 4 or 5 of them, while I can tell for sure that I needed to
implement workarounds for the restrictions that come with the wrappers a
lot more often than those 5 times.
From my point of view you're absolutely right. The API functions are
super awesome and useful if you actually need them, but _if not_ - which
applies to really many scripts - the burden in the shape of the security
layer that comes with the inevitable accessebility of the API functions
is pretty nasty.
> I believe it useful to separate the conceptual idea from its
> implementation details.
True :)
Greetings, Chris
P. S.: Sorry for misspelling your name in the last e-mail, Johan, but
when I noticed the typo it was too late already, and sending a
typo-correction mail is annoying, especially if the correct word is obvious.
I proposed much the same in 2009. [1] But with even more words,
because that also involved a potential method to _keep_ GM_ apis while
running in the page. More complicated.
Short version: I think it's strongly worth considering. It's not
without pitfalls and design issues, but it is probably very valuable.
Longer version: I know only about half of scripts seem to use any APIs
at all [2] so they wouldn't mind losing them. And the majority of the
rest seem to be something you could accomplish with HTML5 features.
Various possibly crazy ideas:
* Something like a "@grant GM_xmlhttprequest" header which would, when
present, force you into the sandbox and put that API in the sandbox
(perhaps with sniffing for legacy scripts? perhaps with @grant none to
turn it off?) would make sense. And otherwise, you run right in the page.
* Perhaps 0.9 adds the last big missing killer feature (updates), then
1.0 goes with the big breaking changes like this. (And maybe dropping
Firefox 3 support. It's getting more annoying, seemingly by the day.)
Possibly with a different extension ID, so that it's much easier for
anyone who "needs" to keep 0.9 to be able.
* We could build/pick one of the "cross browser compatible" type scripts
out there and include by default a set of closure-privately-scoped
functions with legacy names but new HTML5 based (thus slightly
different) features.
[1]
http://groups.google.com/group/greasemonkey-dev/browse_thread/thread/9f74ff190736f179
[2] http://www.greasespot.net/2009/11/greasemonkey-api-usage.html
I agree. A lot remains to be decided before we can build this. But we
should build this.
The 1.0 milestone now exists:
https://github.com/greasemonkey/greasemonkey/issues?milestone=29&state=open
And is intended for figuring out and tracking these issues.
On 08/30/2011 09:22 PM, Johan Sundström wrote:I agree. A lot remains to be decided before we can build this. But we should build this.
User scripting is webby. The javascript sandbox is seriously unwebby.
The mozilla sandbox is the javascript "Quirks Mode" of user scripting.
What I want is a userscript "standards mode", where web standards work.
Without any of the GM_* APIs. (Yes, not even the "native" GM_addStyle.)
Ideally, I'd want it to be Greasemonkey's default execution mode too.
Or something close, like only triggering if the code matches /GM_(APIs)/.
The 1.0 milestone now exists:
https://github.com/greasemonkey/greasemonkey/issues?milestone=29&state=open
And is intended for figuring out and tracking these issues.
Thoughts about adding this second, webby, no-privileges execution mode?
Hi Anthony,
although I'm definitely looking forward to run certain scripts in
content scope, I wonder what benefit I have from adding single "@grant
GM_anyFunction" statements, when inserting none automatically detects
the best mode? I mean, adding any "@grant" statement would only be
additional work for me, plus that I limit my freedom by the header
already, even if I don't use the API.
As there are only the two states (1: access to API which requires legacy
mode; 2: no access to API which allows content scope) a @noapi keyword
would be more sensible IMO. Adding this keyword invalidates the calls of
GM API functions (syntax errors, like you suggested), but is also the
ONLY way to make a script run in content scope. No need for
autodetection, and no need to implement the ability to grant access to
specific API functions. "Access to all or don't use any" is the motto ;)
Chris
although I'm definitely looking forward to run certain scripts in content scope, I wonder what benefit I have from adding single "@grant GM_anyFunction" statements, when inserting none automatically detects the best mode? I mean, adding any "@grant" statement would only be additional work for me, plus that I limit my freedom by the header already, even if I don't use the API.
As there are only the two states (1: access to API which requires legacy mode; 2: no access to API which allows content scope) a @noapi keyword would be more sensible IMO. Adding this keyword invalidates the calls of GM API functions (syntax errors, like you suggested), but is also the ONLY way to make a script run in content scope. No need for autodetection, and no need to implement the ability to grant access to specific API functions. "Access to all or don't use any" is the motto ;)