Run user script on clicking greasemonkey button

2,862 views
Skip to first unread message

saruke

unread,
Nov 1, 2009, 4:01:13 PM11/1/09
to greasemonkey-users
Hi
Is there a way to run the user script on clicking the greasemonkey
button on the firefox browser?

Thanks in advance,
Saruke

qufighter

unread,
Nov 1, 2009, 6:47:28 PM11/1/09
to greasemonkey-users
After greasemonkey is enabled by clicking the icon you must refresh
the page to execute the script. Scripts that attach and run an onload
event for example would not function properly with clicking the icon
to run it as you described. If you want to execute your code
optionally you must add your own button to the page using
createElement, addEventListener, setAttribute and appendChild

Anthony Lieuallen

unread,
Nov 2, 2009, 9:39:04 AM11/2/09
to greasemon...@googlegroups.com
On 11/01/09 16:01, saruke wrote:
> Is there a way to run the .. script on clicking [a] button ..

I think you're looking for bookmarklets.

I.E. http://www.squarefree.com/bookmarklets/

BD

unread,
Nov 2, 2009, 2:25:29 PM11/2/09
to greasemon...@googlegroups.com
There is the Gm menu system (I think that still works), and I have made bookmarklets and GmScripts communicate, which might be a "no-no" due to security issues and that sort of thing. Although maybe you just need a 'simple' bookmarklet. It sure would be nice to have bookmarklets that weren't stored as bookmarks, though. It's a major pain to create them and edit them and look at them and document them, etc. Someone should make an extension for that. Kind of a cross between Greasemonkey and bookmarklets. With an accessible toolbar. It would be nice to have a Gm iconic Toolbar. I don't know if that's in the requests, or not.

saruke

unread,
Nov 2, 2009, 3:21:20 PM11/2/09
to greasemonkey-users
Thank you all for the response.

@qufighter
I want to enable other users to run the script optionally on some
pages which they desire to run it on. So I do not have control on the
page to create a button or any other element.

@Anthony
Bookmarklets can work for me, but I would keep this as a fallback
option.

@BD
A menu for greasemonkey to enable such selective running of scripts
would be great! Do you know if I can provide such a button by creating
a firefox extension? I can try to convert my script to an extension
using User Script Compiler -- http://arantius.com/misc/greasemonkey/script-compiler

Anthony Lieuallen

unread,
Nov 2, 2009, 3:58:41 PM11/2/09
to greasemon...@googlegroups.com
On 11/02/09 15:21, saruke wrote:
> A menu for greasemonkey to enable such selective running of scripts
> would be great!

You're looking for GM_registerMenuCommand() . It's there and works, but
is definitely not the best feature.

saruke

unread,
Nov 2, 2009, 5:09:37 PM11/2/09
to greasemonkey-users
Thanks Anthony, a greasemonkey browser toolbar would be more helpful
for my purpose so that the script can be run by any user by clicking
only once.

cc

unread,
Nov 3, 2009, 12:48:07 AM11/3/09
to greasemon...@googlegroups.com
It occurs to me that Jetpack (http://jetpack.mozillalabs.com/) is
probably able to do what you're looking for, though it's beta software
(if even that). Jetpack's difficulty of programming is roughly the same
as Greasemonkey's, in my experience, but there are rather more APIs
available (though not of the finished quality that Greasemonkey has, and
the coverage is uneven). Check it out!

gollum

unread,
Nov 3, 2009, 3:31:14 AM11/3/09
to greasemonkey-users
There is also an older FF extension (haven't seen any activity for a
while) called Chickenfoot http://groups.csail.mit.edu/uid/chickenfoot/
This may(/may not) be helpfull.
Reply all
Reply to author
Forward
0 new messages