Stuck with this lil script ;/

Subscribe to Stuck with this lil script ;/ 3 posts, 2 voices

 
vBm Scriptwright

What i'm trying to do ?
Simple ... im checking for specific page and after i find it (/user.php?user= or /user.php?uid= ) i want to search for all images from imageshack/photobucket/xs and then to remove image tags if possible.
This is the code i came up with so far

if((document.location.pathname + document.location.search) == ('/user.php' + document.location.search)){
var xpath = "//img[contains(@src, 'imageshack.us')] | //img[contains(@src, 'photobucket.com')] | //img[contains(@src, 'xs.to')]";
var results = document.evaluate( xpath, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < results.snapshotLength; i++) {
console.log(results.snapshotItem(i));
// here should go img -> link code
}
}

Since i check /user.php?nick=Shittobukai im getting this output from console.log ->

< img src="http://img180.imageshack.us/img180/2883/chaoswb4.jpg" >
< img src="http://xs218.xs.to/xs218/07353/ptftc.png" >
< img src="http://i214.photobucket.com/albums/cc8/ini_ca/vbmcapre-1.png" >

question is how to disable displaying images on page and just leave links to those images so user can visit 'em with clicking ... something like this ->

http://img180.imageshack.us/img180/2883/chaoswb...
http://xs218.xs.to/xs218/07353/ptftc.png
http://i214.photobucket.com/albums/cc8/ini_ca/v...

tnx in advance

 
lazyttrick Scriptwright

probably something like this:

var link, img;
for (var i = 0; i < results.snapshotLength; i++) 
{
   img = results.snapshotItem(i);

   link = document.createElement('a');
   link.setAttribute('href',img.getAttribute('src'));
   link.innerHTML = img.getAttribute('src');//link text

   img.parentNode.appendChild(link);//add link
   link.parentNode.removeChild(img);//remove img
}

 
vBm Scriptwright

tnx so much ... that helped big time
also added you to thanks note for Omerta Beyond