There are 8 previous versions of this script.
// eBay Completed Items ~ Version 1.5
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Coder: Keith Hopkins
//
// ==UserScript==
// @name eBay - Completed Items UK
// @description This script adds link to the completed items search using the auction title for currently viewed item
// @namespace
// @include http://*.ebay.tld/*
// ==/UserScript==
/*
This script is designed to help you easly find the price of completed items that match the item you are looking at on eBay
Works out average price for items that have sold
Version History
1.5 - Fixed for eBay Layout Changes
1.4 - Fixed for eBay Layout Changes
1.3 - Fixed title and Popup Window bug
1.2 - Works out average for Completed Items
1.1 - Auction Title is now Editable
*/
var popupwin = 1; //POPUP WINDOW
var node
var idLoc = location.pathname.indexOf("QQitemZ");
var itemId, endLoc;
if (idLoc != -1)
{
idLoc += 7;
endLoc = location.pathname.indexOf( "QQ", idLoc );
itemId = location.pathname.substring( idLoc, endLoc );
} else {
idLoc = location.search.indexOf("&item=");
if ( idLoc != -1 )
{
idLoc += 6;
var endLoc = location.search.indexOf( "&", idLoc );
if ( endLoc <= idLoc )
{
endLoc = location.search.length;
}
itemId = location.search.substring( idLoc, endLoc );
}
}
var search,watchLink;
var allElements, thisElement;
allElements = document.getElementsByTagName('h1');
for (var i = 0; i < allElements.length; i++) {
thisElement = allElements[i];
//alert(thisElement.textContent.length);
if(thisElement.textContent.length > 0){
search = thisElement.textContent;
}
}
nodes = document.getElementsByTagName('a');
for(x = 0; x < nodes.length; x++)
{
node = nodes[x];
if(node.id == "d_ttl_addToList")
{
watchLink = node//.offsetParent;
//insertGixenHTML(appendNode);
break;
}
if(node.id == "-99_ttl_addToList")
{
watchLink = node//.offsetParent;
//insertGixenHTML(appendNode);
break;
}
}
searchUrl = "http://search.ebay.co.uk/ws/search/SaleSearch?satitle=" + search +"&fis=2"
if (watchLink != null )
{
var completed = document.createElement("a");
if (popupwin==1)
{
completed.addEventListener("click", popup, false);
completed.href = '#';
} else {
completed.href = searchUrl;
completed.target = "_GM";
}
completed.title = "Find Completed Auctions for: " + search;
watchLink.parentNode.insertBefore(completed, watchLink.nextSibling);
completed.appendChild(document.createTextNode("| View Completed Items |"));
} else {
// Excape if no item number is found
}
//alert('Item# ' + itemId + '\nTitle ' + search + '\n' + watchLink);
//Average
var allLinks, thisLink;
allLinks = document.evaluate(
"//td[@class='prc bidsold g-b']",
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
var averagePrice = 0.00;
var price;
for (var i = 0; i < allLinks.snapshotLength; i++) {
thisLink = allLinks.snapshotItem(i);
var price = thisLink.innerHTML;
price = price.replace("£","");
price = price.replace("<i>","");
price = price.replace("</i>","");
price = parseFloat(price);
averagePrice = averagePrice + price;
}
if (averagePrice > 1) {
averagePrice = averagePrice/i;
//alert("Average Price: " + Math.round(averagePrice));
var logo = document.createElement("div");
logo.innerHTML = '<div style="margin: 0 auto 0 auto; ' +
'border-bottom: 1px solid #000000; margin-bottom: 5px; ' +
'font-size: large; background-color: #000000; ' +
'color: #ffffff;"><p style="margin: 2px 0 1px 0;"> ' +
'<center>Average Price: ' + Math.round(averagePrice) +
'</center></p></div>';
document.body.insertBefore(logo, document.body.firstChild);
}
function popup() {
input = prompt("Completed item Search Term",search);
if(input!=null)
{
searchUrl = "http://search.ebay.co.uk/ws/search/SaleSearch?satitle=" + input +"&fis=2";
window.open(searchUrl, '', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=826,height=430,left=124,top= 84');
}
}