[Greasemonkey] 3b function Bug?

Aaron Boodman zboogs at gmail.com
Sun Apr 24 19:58:59 EDT 2005

I now understand your problem. Took awhile to decode.

You've declared a function:

function monkey() {

and before, you were able to do something like onclick="monkey()" and
it worked. Now, not so much.

This is caused by the fact that in .3 greasemonkey, the anonymous
function wrapper which has been recommended since the very first
version is applied for you automatically. This is a byproduct of the
changes that Jeremy was talking about.

You do bring up a very good point that ideally, any script that works
on mozilla when delivered by the server also works when installed via
greasemonkey. However that's just not currently possible within other

There's only a very small class of scripts that have this problem, and
you're just lucky #1. To get around it, I recommend that you declare
your functions like this:

window.monkey = function() {

This is basically(*) the same as what you were doing before and should
solve your problem. In the future, hopefully we can solve this.


* functions proper are available even if declared after their first
use, whereas function literals aren't. Other than that, the same.
Shouldn't matter for you.

On 4/24/05, Gary <gary at inmendham.com> wrote:
> quote:--"Are you trying to use GM_* but still be cross-browser?  How
> would that work?"
> Well in my opinion, it works [did] pretty damn good
> http://donotgo.com/tb0503.htm
> With the old greasemonkey I could make a few minor changes to the same
> .js file and have it work-- hard coded in the page ( IE or moz), have
> greasemonkey automatically load it, or inject it with a single click
> using IE.
> I figure I probably can figure a way around your limitation (but
> certainly don't want to) and I have little doubt that the forces of evil
> will not be stopped by any deliberate (Security) limitation you place on
> functionality. I realize you're all thinking of gm in terms of lots of
> little scripts, doing kind of little things... I think it makes more
> sense to encourage more aggressive use of the client side power grease
> monkey provides-- I'm almost thinking of building a 500 or 600 K "user
> script" the would provide always on, always instant, access to the best
> of the dmoz/google directory. Anyway, if I have a vote, I vote no to
> security at a cost of functionality. It really isn't that hard "to out"
> the bad players and let the innocent roam free.
> _______________________________________________
> Greasemonkey mailing list
> Greasemonkey at mozdev.org
> http://mozdev.org/mailman/listinfo/greasemonkey

More information about the Greasemonkey mailing list