// ==UserScript==
// @name        Auction Godaddy PageRank Checker
// @author	Philip
// @email	philip@tiangson.com
// @namespace   http://www.tiangson.com
// @description Adds a pagerank/backlink display next to every domain listed on auctions.godaddy.com.
// @include     https://auctions.godaddy.com/*
// ==/UserScript==

//Trim Function - Alisin ang extra spaces
function trim(s){
	if((s==null)||(typeof(s)!='string')||!s.length)return'';return s.replace(/^\s+/,'').replace(/\s+$/,'')}

//Loop through all domains listed and add pagerank image
var result = document.evaluate( "//td[@class='sItem']/a[@style] | //td[@class='sItemA']/a[@style]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null );

if(result.snapshotLength < 1)	return;
for ( var i = 0; i < result.snapshotLength; i++ )
{
	thisElement = result.snapshotItem(i);
	thisText = trim(thisElement.title);
	if(!thisText)	thisText = trim(thisElement.text);
	thisText = thisText.replace("View details for ", "");

	newElement = document.createElement('div');
	newElement.innerHTML = '<img src="http://www.free-pagerank-checker.com/pr.php?url=http://' + thisText + '"/>';
	thisElement.parentNode.insertBefore(newElement, thisElement.nextSibling);
}

