[Greasemonkey] add prefetch attributes
chris feldmann
cfeldmann at gmail.com
Mon May 16 14:51:00 EDT 2005
" I have no idea how I can confirm whether Firefox is prefetching or not."
Sounds like yet another perfect use for the Live HTTP Headers extension:
http://livehttpheaders.mozdev.org. <http://livehttpheaders.mozdev.org>
On 5/16/05, Leo Zelevinsky <leo.zelevinsky at gmail.com> wrote:
>
> Thanks a lot!
>
> By patching together pieces of other scripts, I was able to add the
> prefetch attribute (though I just did link.rel="prefetch" and used a
> loop instead of a getbyId since I don't think it has an ID).
>
> What you say about it being too late makes a lot of sense - I have no
> idea how I can confirm whether Firefox is prefetching or not. Testing
> it is difficult as the web site I'm going to (TWOP) is reporting back
> a lot of dropped connections with or without my script :(.
>
> I'll try both the xmlhttprequest and the other way and see if I can
> get it to make a difference.
>
> Thanks again.
>
> On 5/16/05, Nikolas Coukouma <lists at atrus.org> wrote:
> > Leo Zelevinsky wrote:
> >
> > >Thanks!
> > >
> > >The script is quite different than what I was envisioning though -
> > >what it seems to do is preload an image, after determining the image
> > >path.
> > >
> > >What I am thinking of doing is not handling any of the prefetching
> > >itself - let Firefox do it, but just to alter the settings on the link
> > >to add the prefetch attribute.
> > >
> > >I guess if that's hard to do for some reason I could try to use
> > >GM_xmlhttpRequest instead.
> > >
> > >And the pages I'm preloading aren't images anyway, though certainly
> > >the idea of preloading the image is very useful too.
> > >
> > >Thanks again though - any help on altering an element in the way I
> > >want appreciated (I'm currently reading the 'Diving into greasemonkey'
> > >book - so maybe that will answer my questions as well.
> > >
> > >
> > You can add " prefetch" to rel, but I doubt Firefox will act on it. The
> > page is already half-loaded by the time your script gets to it. Using
> > GM_xmlhttpRequest is the best way to go. Dive into Greasemonkey and the
> > Greasemonkey homepage have documentation for it. Basically, all you need
> > to do is:
> > GM_xmlhttpRequest({ url: "http://something", method: "get" });
> > Normally you'd set handlers for when the data arrives, but that doesn't
> > matter since you just want the request to be made.
> >
> > As for modifying elements, you can usually do:
> > var elm = document.getElementById( "something" );
> > elm.attr = "value";
> >
> > for example,
> > elm.rel += " prefetch";
> >
> > The DOM way of doing this is using hasAttribute, getAttribute,
> setAttribute:
> > elm.hasAttribute( "rel" ); // does it have a rel attribute?
> > var str = elm.hasAttribute( "rel" ); // get the current value of rel
> > elm.setAttribute( "rel", str + " prefetch" ); // set the value of rel
> >
> > There's a lot more. You can read the W3C's DOM spec, or check out XUL
> > Planet's reference
> > http://xulplanet.com/references/objref/
> >
> > -Nikolas Coukouma
> >
> > >On 5/16/05, Julien Couvreur <julien.couvreur at gmail.com> wrote:
> > >
> > >
> > >>Sure, there is a script that does that already for the AppleGeeks
> site:
> > >>
> http://www.warwick.ac.uk/~esudbi/greasemonkeyscripts/applegeeks_preload.user.js
> > >>
> > >>Besides looking for links that say "next", you could also look for
> rel="next"
> > >>
> > >>Cheers,
> > >>Julien
> > >>
> > >>On 5/16/05, Leo Zelevinsky <leo.zelevinsky at gmail.com> wrote:
> > >>
> > >>
> > >>>Hi all!
> > >>>
> > >>>I would like to take advantage of the prefetch feature of firefox on
> > >>>non-prefetch-aware webpages. Can I use Greasemonkey for this? I did
> > >>>some searches with no luck.
> > >>>
> > >>>It seems like it should be relatively straightforward so I'm
> wondering
> > >>>why I can't find anything. For instance, I'd want to add to a link
> > >>>that says "Next" the prefetch attribute automatically.
> > >>>
> > >>>Any pointers would be much appreciated. Thanks!
> > >>>
> >
> > _______________________________________________
> > Greasemonkey mailing list
> > Greasemonkey at mozdev.org
> > http://mozdev.org/mailman/listinfo/greasemonkey
> >
> _______________________________________________
> Greasemonkey mailing list
> Greasemonkey at mozdev.org
> http://mozdev.org/mailman/listinfo/greasemonkey
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mozdev.org/pipermail/greasemonkey/attachments/20050516/0e698668/attachment.htm
More information about the Greasemonkey
mailing list