[Greasemonkey] help with user script

Tom Sonsuwan tom.sonsuwan at speedydomainregistration.com
Mon Aug 29 04:07:58 EDT 2005


Thanks John,

Great start.

Is there any way to make the html of the links look like this:
normal:   <a href=someurl>Some anchor</a>
new:  <a href=someurl>Some anchor</a> - <img 
src=image.php?url=someurl>

Notice the image tag.   Each link will have different image by 
sending script the url you want image for.

Can this be done?

Tom

----- Original Message ----- 
From: "John Plsek" <gm at plsek.id.au>
To: <greasemonkey at mozdev.org>
Sent: Monday, August 29, 2005 2:41 AM
Subject: Re: [Greasemonkey] help with user script


Here's a little something I just knocked up ;-) adds a smiley 
after any
link that has "page" in the anchor text

// ==UserScript==
// @name          anchorImage
// @description      Test
// @include       *
// ==/UserScript==
(function() {
  var style=[
    "a.smilied:after{content: url(",
    "data:image/gif;base64,",
    "R0lGODlhDwAPANUAAAAAAI2z2D9mswAzmbfQ53Wj0f///2WPxi1Wqai83M/g75Sn",
    "zZa53LzT6BFAn4Sk0GaZzKzI48/W4pO22XWby9bj8KzA3oSt1i9crYyl1kpts32o",
    "1JS428XZ6tDW45y+3qbE4a/K5N3p863F3pGt1DJfrkRstWaZzHuezcPY6yhXq5q0",
    "2O3t7QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
    "AAAAAAAAAAAAAAAAACH5BAUUACwALAAAAAAPAA8AAAaWQJaQtdA4Bg7NYjj0IAQW",
    "RYdAEiAkQ4kjIeo0QmDQw4FlIbgAQCQCSn9QCKKmS1iDPnh8qRhtRAB3HwAchChG",
    "FSlgAHgcAAGPAUcKdSB3hAEXmRdIHSGAHwwMmBcAGxtJK55pq6sFB0ombAAGtLQA",
    "BQUqSwgPd6y3rnEsHg4PeBOYG64OHk0IGA/IFxQlCM1MckdJS0NBADs=",
    ");}"
  ].join("");
  var head=document.getElementsByTagName("head")[0];
  var ele=document.createElement('link');
  ele.rel='stylesheet';
  ele.type='text/css';
  ele.href='data:text/css;charset=utf-8,'+escape(style);
  ele=head.appendChild(ele);
  var xpath="//a[contains(text(), 'page')]";
  links =
document.evaluate(xpath,document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);
  for (var i = 0; i < links.snapshotLength; i++) {
    node = links.snapshotItem(i);
    node.className+=" smilied";
  }
})();

Tom Sonsuwan wrote:

>Hello,
>
>Been trying to write a script to add an image to the end of
>links on a page.
>Only links with certain anchor text would be selected.
>
>Tried unsuccessfully for couple of days now.
>
>Please help.
>
>_______________________________________________
>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



More information about the Greasemonkey mailing list