ebayFindContactInfo

By * Last update Oct 24, 2008 — Installed 215 times.

There are 1 previous version of this script.

// ==UserScript==
// @name           ebayFindContactInfo
// @namespace      none
// @description    adds a link in "My eBay" to every item won which 'finds' the contact information of the corresponding seller
// @include        http://my.ebay.tld/ws/eBayISAPI.dll*
// ==/UserScript==

var won = document.evaluate("//TABLE[@id='Won']//TR[@class='BDtC4n']", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
var tld = document.URL.match(/^http:\/\/my.ebay.([a-z]{2,3}(?:\.[a-z]{2,3})?)\//)[1];
for (var i = 0; i < won.snapshotLength; i++){
	var wonrow = won.snapshotItem(i);
	var links = document.evaluate(".//A[@href]", wonrow, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
	var userid, itemid;
	for (var j = 0; j < links.snapshotLength; j++){
		var url = links.snapshotItem(j).getAttribute("href");
		var res = /^.*&requested=([^&]+).+iid=(\d+).*$/.exec(url);
		if (res != null) { userid = res[1]; itemid = res[2]; break;}
	}
	if (userid === undefined) continue;	// could not determine the other user's id and/or the item id

	var actioncell = document.evaluate(".//TABLE[@class='NewActionBaseTable']/parent::*/parent::*", wonrow, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
	var requestLink = document.createElement("A");
	requestLink.setAttribute("href", "http://contact.ebay." + tld + "/ws/eBayISAPI.dll?MfcISAPICommand=UserQuery&otheruserid=" + userid + "&itemno=" + itemid);
	requestLink.appendChild(document.createTextNode("Request Contact Info"));
	actioncell.appendChild(requestLink);
}