[Greasemonkey] Preventing off-site resources
Michael Preslar
mike at lordlegacy.com
Sun Jan 21 18:03:06 PST 2007
I'm hoping there are folks on this list that can help me out, or at
least point me in the right direction.. The archives at
http://mozdev.org/pipermail/greasemonkey/ shows 5 messages since Nov..
Moving on..
My setup: WinXP, Firefox 2.0.0.1, and GM 0.6.6.2006
I'm wanting to create a GM script (my first!) that prevents pages from
loading "off-site" resources.. Meaning: If I hit
http://www.foobar.com/index.html .. The GM script should allow this
index.html to bring in anything from *.foobar.com, and would prevent the
following resources from being loaded:
- <img src="http://(anywhere but *.foobar.com/image.jpg">
- <iframe src="http://(anywhere but *.foobar.com/whatever.ext">
- <frame src="http://(anywhere but *.foobar.com/whatever.ext">
- <link href="http://(anywhere but *.foobar.com/whatever.ext">
- <script src="http://(anywhere but *.foobar.com/whatever.ext">
etc..
After checking GM user scripts on the web and other sites that google
gave, I was able to prevent off-site images by using
document.evaluate("//img[@src]",....)
Next, I tried to do the same with off-site javascripts, but I ran into
something that I don't know how to work around..
Using an http://www.mydom.com/index.html that has a <script
src="http://www.mydom.com/goodscript.js"> and a <script
src="http://www.my-other-dom.com/badscript.js">..
Firefox would download my index.html .. And then download the referenced
*.js scripts.. and THEN execute my GM script.. goodscript.js and
badscript.js would execute before my GM script was processed, when I'd
prefer that these files not be downloaded at all.
I'm guessing that Firefox downloads these external resources by my GM
script because I'm using document.evaluate() .. I'm thinking that if I
accessed the page's raw html and went from there, I'd not have this
problem.. But I have yet to find a function that'll return the raw html
of the entire page..
Summing up:
1) Just for clarification.. Does FireFox download all resources a web
page uses before executing GreaseMonkey scripts?
2) How can I access the entire raw html source of the loaded page?
Or maybe you guys know of a GM script or FF plugin/ext that already
accomplishes what I'm after..
Any help would be appreciated!
--
Michael
More information about the Greasemonkey
mailing list