[greasemonkey-users] Newbie question

23 views
Skip to first unread message

applepie3

unread,
Aug 22, 2011, 4:25:59 AM8/22/11
to greasemon...@googlegroups.com

Hi,
Im not sure if this is a stupid question.

But i was wondering how greasemonkey works. Does it insert the javascript
code into the page source? If so where in the page source?
--
View this message in context: http://old.nabble.com/Newbie-question-tp32309372p32309372.html
Sent from the GreaseMonkey List mailing list archive at Nabble.com.

LWChris@LyricWiki

unread,
Aug 22, 2011, 5:25:20 PM8/22/11
to greasemon...@googlegroups.com
Am 22.08.2011 10:25, schrieb applepie3:
> Hi,
> Im not sure if this is a stupid question.
>
> But i was wondering how greasemonkey works. Does it insert the javascript
> code into the page source? If so where in the page source?

You might want to read this:
http://en.wikipedia.org/wiki/Greasemonkey#Technical_details

Chris

applepie3

unread,
Aug 22, 2011, 10:09:24 PM8/22/11
to greasemon...@googlegroups.com

Hmm, thanks.

> --
> You received this message because you are subscribed to the Google Groups
> "greasemonkey-users" group.
> To post to this group, send email to greasemon...@googlegroups.com.
> To unsubscribe from this group, send email to
> greasemonkey-us...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/greasemonkey-users?hl=en.
>
>
>

--
View this message in context: http://old.nabble.com/Newbie-question-tp32309372p32315767.html

LWChris@LyricWiki

unread,
Aug 23, 2011, 9:14:57 AM8/23/11
to greasemon...@googlegroups.com
Am 23.08.2011 04:09, schrieb applepie3:
> Hmm, thanks.

Hm, okay, I know this article isn't so much about the technical details,
but the main thing "invokes the script" is mentioned. For more detailed
answers, your question is maybe better addressed to greasemonkey-dev
group. In that group you can also find a lot of messages to technical
details and links to the code repository at github.

Chris

RodMcguire

unread,
Aug 23, 2011, 9:05:57 PM8/23/11
to greasemon...@googlegroups.com
Modern versions of Greasemonkey for Firefox put the userscript in a sandbox for security reasons.

The code there is run when the DOMContentLoaded event fires for the page.

http://wiki.greasespot.net/Sandbox
http://wiki.greasespot.net/Security
http://wiki.greasespot.net/DOMContentLoaded

applepie4

unread,
Aug 28, 2011, 4:59:26 AM8/28/11
to greasemon...@googlegroups.com

so greasemonkey loads before the page event finish loading?
That would explain my code firing several times... i think.

Is there a way to delay when the code fires?
I wrote an automation script that works perfectly IF i run it using firebug
after the window fully loads.

i guess i could run some junk loop for 5 seconds, but depending on the code
it might jam up my firefox/pc.
--
View this message in context: http://old.nabble.com/Newbie-question-tp32309372p32350632.html

John Plsek

unread,
Aug 28, 2011, 6:03:33 AM8/28/11
to greasemon...@googlegroups.com
no, greasemonkey runs the script once DOMContentLoaded is fired ... by definition, the DOM Content has fully Loaded at this point

--

applepie4

unread,
Aug 28, 2011, 6:09:10 AM8/28/11
to greasemon...@googlegroups.com

hmm, then how are those facebook game auto-script done..

i will dl a few script and take a look

--
View this message in context: http://old.nabble.com/Newbie-question-tp32309372p32350799.html

Matt Sargent

unread,
Aug 28, 2011, 3:51:34 PM8/28/11
to greasemon...@googlegroups.com
You can add an event listener to wait for some other DOM event, and then
trigger your code from that.

Kwah

unread,
Aug 28, 2011, 5:40:23 PM8/28/11
to greasemon...@googlegroups.com
Sounds like you're having problems with your @includes matching
multiple frames on a page, and the script will be executing on each of
them for every pageload.

For the facebook games, IIRC they run on non-facebook servers via an
iframe and many make use of AJAXy code - in other words, clicking a
link won't necessarily load another page and consequently won't
trigger the user-script to be executed. As suggested in another reply,
you will likely need to listen for other events like node inserted
etc.


Actually, @includes are probably the issue - the game's page isn't run
on a facebook.com page.

applepie4

unread,
Aug 29, 2011, 2:44:02 AM8/29/11
to greasemon...@googlegroups.com

Im not working on a FB game FYI.
It is an auto-login script to claim in-game freebies.

I am using the site's domain name in the @include. I dont know what else to
include since it works across several pages including domain/sub-domain.

Unless i learn to use AJAX. Or just use a more specific trigger?

Time to read up on AjAX and DOM

--
View this message in context: http://old.nabble.com/Newbie-question-tp32309372p32354707.html

LWChris@LyricWiki

unread,
Aug 29, 2011, 4:15:04 PM8/29/11
to greasemon...@googlegroups.com
Am 29.08.2011 08:44, schrieb applepie4:
> Im not working on a FB game FYI.
> It is an auto-login script to claim in-game freebies.
>
> I am using the site's domain name in the @include. I dont know what else to
> include since it works across several pages including domain/sub-domain.
>
> Unless i learn to use AJAX. Or just use a more specific trigger?
>
> Time to read up on AjAX and DOM

Common ways to delay / customize the execution of a function:

> hello = function () {
> document.title="Hello World";
> }
+ one of these methodes (one per line):
> window.addEventListener("load", hello, false); // Waits for all
> contents, not only for DOM content to be loaded before the function is
> called
> GM_registerMenuCommand("Say hello", hello); // Puts a clickable item
> "Say hello" into the Greasemonkey menu to execute the function manually
> setTimeout(hello, 5000); // Waits five seconds before it calls the
> function

Chris

Reply all
Reply to author
Forward
0 new messages