[Greasemonkey] help with user script

John Plsek gm at plsek.id.au
Tue Aug 30 00:27:32 EDT 2005

Christopher Lam wrote:

> I usually use javascript to get them links instead of XPath; I'm more 
> used to them.
> Plus I use getAttribute and setAttribute to retrieve the a.href and 
> set the img.src.
> How's that for an attempt?
Cool, but I like XPath's contains() function, oh, and you forgot to add 
" - " between the link and the image ;-)

One thought, can't you just use document.links? (not sure if that's one 
of the "limitations" imposed by GM 0.5+)

so, the script would become:

  for (var i=0; i < document.links.length; i++) {
    a = document.links[i];
    if (a.textContent=='Fx 1.0.6') {
      imgsrc = a.getAttribute('href');
      img = document.createElement('img');
      a.parentNode.insertBefore (img, a.nextSibling);
      a.parentNode.insertBefore (document.createTextNode(" - "), 

however, I've never "heard" of the "textContent" property ... must've 
slipped under my radar

More information about the Greasemonkey mailing list