Processing of IFRAMEs in GreaseMonkey

462 views
Skip to first unread message

Vortexx

unread,
Mar 5, 2007, 4:42:37 PM3/5/07
to greasemonkey-users
Hi there!

I am going to write an FF plugin that will alter certain page
contents. Recently I discovered that GreaseMonkey is perfect for such
things.
However, there are many pages that contain <IFRAME> elements, which
are actually other nested pages. Does anybody know how exactly
GreaseMonkey processes such nested pages?
Will it call my javascript for the main page only, or for every IFRAME
too? What will happen if I re-assing the entire
document.body.innerHTML property? Will the page be re-processed by
GreaseMonkey in that case? What if the reassigned HTML contains
IFRAMES - will they be reloaded and processed again?
I am not really going to do exactly these things, but I need a better
understanding how GreaseMonkey works.

Best regards,
Vortexx.

Anthony Lieuallen

unread,
Mar 5, 2007, 4:49:54 PM3/5/07
to greasemon...@googlegroups.com
On 3/5/2007 11:42 AM, Vortexx wrote:
> Will it call my javascript for the main page only, or for every
> IFRAME too?

Every frame, "I" or not is a page. They all get hit.

> What will happen if I re-assing the entire document.body.innerHTML
> property? Will the page be re-processed by GreaseMonkey in that case?

Er .. re-assigning? No. Only on document load.

> What if the reassigned HTML contains IFRAMES - will they be reloaded
> and processed again?

A new frame is a new document to load, so yes.

Long and short is, if it generates an onload event (really:
DOMContentLoaded, because that's a bit earlier), GM will evaluate it.
If not, not.

Vectorspace

unread,
Mar 5, 2007, 5:05:27 PM3/5/07
to greasemon...@googlegroups.com
Greasemonkey takes no account for frames, only pages. If your script is
set to run on www.google.com it will, regardless of if the page is
loaded directly or in a frame. If your script is set to run on
www.foo.com only, it will not load in any frames the page might have

http://www.blah.com - a web page
http://www.blah.com/foo - a frame, iframe., or object in the page
http://www.blah.com/goo - another frame, iframe., or object in the page
http://www.wingo.com - another frame, iframe, or object on the page
- this one from a different domain

If the includes for your script only says http://www.blah.com then it
will not apply to any of the frames
If the includes is http://www.blah.com* then it will apply to the main
page, the foo frame, and the goo frame - any page that starts
http://www.blah.com. It will not start on http://www.wingo.com
If the includes are http://www.blah.com* and http://www.wingo.com then
it will work on all three

RodMcguire

unread,
Mar 5, 2007, 6:31:41 PM3/5/07
to greasemonkey-users
On Mar 5, 11:42 am, "Vortexx" <vde...@gmail.com> wrote:
> However, there are many pages that contain <IFRAME> elements, which
> are actually other nested pages. Does anybody know how exactly
> GreaseMonkey processes such nested pages?

If the top page and the frame URLs pass the @include test then your GM
script will run on all.

If you do any x.innerHTML = '...<iframe ...>...'
then that iframe's url will be (re)loaded and if it is @included then
your GM script will run.

If you want to make your GM script run differently on frames (like
maybe do nothing) you can check (window.top == window) to see if the
page loaded in a frame and what type, or if your script is causing the
frames then you can do something like <iframe src="foo.htm#myFrame">
and then have the script check for (document.location.hash ==
'#myFrame).

krsnik02.abel

unread,
Mar 5, 2007, 10:52:52 PM3/5/07
to greasemon...@googlegroups.com
I get this when i try to install Hello world example:
No chrome package registered for
chrome://navigator/locale/navigator.properties .
No chrome package registered for
chrome://navigator-region/locale/region.properties .
No chrome package registered for
chrome://communicator-region/locale/region.properties .
Failed to launch editor: [Exception... "Component returned failure code:
0x80520003 (NS_ERROR_FILE_EXECUTION_FAILED)
[nsIMIMEInfo.launchWithFile]" nsresult: "0x80520003
(NS_ERROR_FILE_EXECUTION_FAILED)" location: "JS frame ::
chrome://greasemonkey/content/utils.js :: openInEditor :: line 121"
data: no]


I've read on http://www.greasespot.net/2005/12/troubleshooting-064.html
that problem is the missing config.xml file. But when i get to my
Progiles\gg19waib.default
file gm_Scripts\config.xml exists...


I have Firefox 2.0.0.2 and gm 0.6.7

Thx

Reply all
Reply to author
Forward
0 new messages