View Full Version : Greesemonkey script, Is this possible

Nov 25th, 2009, 05:53 PM
Alot of people on a forum i go onto try to do little tricks like


I know a little JS. But not really sure on where to start.

I would like it to be displayed as when changing the view of the web page.....


Hidden Link


is this even possible?

page source looks like

<a href="http://img405.imageshack.us/img405/6295/BADPICTURE.jpg" class="postlink" target="_blank">www.google.co.uk</a></div>

any help would be great

Nov 25th, 2009, 11:06 PM
Please re-explain your question. I couldn't make sense out of it.

Nov 26th, 2009, 02:39 AM
Hi, do you know what greese monkey is? it allows complete manipulation of how a web page displays using JS. Its a FF addon.

People often try to hide urls using yabba tags to try get you to go to a dodgy site

her eis an example of GM changing text


I would like it so GM would display a url tag as below

Nice site (www.p***site.com)

when the page is displayed

make sense?

Nov 26th, 2009, 02:40 AM
edit*** sorry double post

Nov 26th, 2009, 03:19 AM
So you basically want to reveal the actual web link for ALL links on a page? That seems like it might end up being a nightmare to me. But that's an opinion.

I use greasemonkey often, but it's more for scraping data. I don't really modify the pages with it.

You said you weren't sure where to start, so maybe this will help get you started. Well, I had pasted some code here, but it didn't work properly. I haven't ever worried about what's inside the HTML tag itself, just the data outside of it.

Here's an idea, but I'm sure there are much better ideas from the guys around here. At least this MIGHT get you started..

// Gather all link information information
var infoFind;
infoFind = document.evaluate (

// cycle through found links
for (var i = 0; i < infoFind.snapshotLength; i++){
rawInfo = infoFind.snapshotItem(i);
bodyHTML = rawInfo.innerHTML;
GM_log(bodyHTML); //print found data to FF error_console

This will grab all the html from the body of the page...again, this may not be the best coding.

Now, you could do a bodyHTML.replace with some regex expression to globally replace all the <a href.... with something that suits your tastes...perhaps just adding a title attribute to the href so that you can mouseover the link and see the actual links.

Honestly...you could probably already find an existing script that does that.

I wish I could be of more help.

Nov 26th, 2009, 02:18 PM
Thanks for your reply, il check out your code.

you have just worried me though as you said something i not thought about.

I doint want all links displayed, sinc eim on a forum it would be a massive mess.

Only the ones in a user post, which leads to a big question, how is it ment to no between a post link or a normal link


Nov 26th, 2009, 03:26 PM
It's actually only this postbody tag i need to grab i think

<div class="postbody"><a href="http://www.badporn.com" class="postlink" target="_blank">www.google.com</a></div>

Dec 2nd, 2009, 12:24 AM
The problem may be with checking this page(is good or bad).
Href and text link may be different ... but

Try this:

// ==UserScript==
// @name an T 6
// ==/UserScript==
ico="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAhBJREFUeNqkk81u00AQx8frtR2HjzjFxc1HI+EmtdqE9l LulTiGiANCFUJBIHHrC1Cp4sAJeAZegRuPAAckUIjEASEBhfQQA6mgMRvHn+xYSQk0rSqx0s+7Ozv/Wc/ujhDHMfxPo6+fkaPWMpwno/Fdzs9pTuSY4Ndz5VsVBMdHOZEoAvgXntU8lbN1o9RYMkr1JSppdbRN850agNPkO9cid0eOBp/luYWbNbSdKADfaVU5VVrP6hfN7UdfYfvxN8jqy6aSLq7j2qEAIf9MgPM7hfKN6rD/njDGAPGcHZK7cLWKayOfAw2JQh5pRBzB5TPa8pqqZvKhvw+O4ySEQR/SaS1/+mx5DX0mNTQMDw5UFYjQzC9cqfrsC3ihC61WC2zbht3NVZ7aR6AzVjXsfWjGUfyc+w+SW/ADAIT/zrVzc5dWCPG03qADNvsE7XYbut0uhJILkewCyENN0Yor6DvWEXyIHB0EeUMv1hZ7/VfgRz2QyBC+2w8SZNFLEAUHMoaxGIO4gRrUkoCnwNO4PVuwLD96p1LigCK6CbpxP2E8R9RUoGaNWQs1qCVBAGVRUhrnC6opwQ9I8 Z3GjNukDcnNayahtIFayli8ZVp6RRb3xTjGE/1TXGzvXtL/2nv69/sVQSyUZipv39hblA3Ae/lit8PNncMv/eGxlSgI4AmjgkrhNXKUE1Yx5sc47m8BBgAHzSyzBIpQmgAAAABJRU5ErkJggg==";

var snapBadImages = document.evaluate("//*[@class='postlink']",

document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);

for (var i = snapBadImages.snapshotLength - 1; i >= 0; i--) {
var el = snapBadImages.snapshotItem(i);
var elh=el.href;
var elt =el.innerHTML ;

if (elh.indexOf(elt) < 0) {
console.log("Cheat"+i+" "+elh+" <> "+elt);

//add icon !
el.innerHTML+='<img style="border:0"src="'+ico+'">' ;