jbidwatchAdder

By * Last update Nov 15, 2007 — Installed 211 times.
// ==UserScript==
// @name           jbidwatchAdder
// @namespace      none
// @include        http://cgi*.ebay.*
// ==/UserScript==

var username, password;

// you may uncomment and set your credentials here
//var username = "myGayUserID";
//var password = "nobodyGivesAFuckAnyway";

var addlink = document.getElementById("watchLinkTop");
if (addlink != null){
	addlink.removeAttribute("ID");
	var addlinkhref = String(addlink.getAttribute("HREF"));
	var item = addlinkhref.match(/&item=(\d+)/)[1];
	addlink.setAttribute("HREF", "http://localhost:9099/addAuction?id="+item);
	addlink.setAttribute("TARGET", "_self");
	addlink.addEventListener("click", function (event) {
		var div = document.getElementById("watchLinkTopDiv");
		while (div.firstChild){
			div.removeChild(div.firstChild);
		}
		div.textContent = "adding ...";
		GM_xmlhttpRequest({method: "GET",
			url: "http://" +
			(username === undefined || password === undefined ? "" : username+":"+password+"@") +
			"localhost:9099/addAuction?id="+item,
			onload: function(responseDetails){
				var div = document.getElementById("watchLinkTopDiv");
				if (responseDetails.responseText.indexOf("HREF=\"\/"+item+"\"") != -1) {
					div.textContent = "added!";
				} else {
					div.textContent = "not added?";
				}
			}
		});
		event.stopPropagation();
		event.preventDefault();
	}, true);
}
addlink = document.getElementById("watchLinkTopDiv");
if (addlink != null){
	var clds = addlink.childNodes;
	for (var i = 0; i < clds.length; i++){
		if (clds.item(i).nodeType == document.TEXT_NODE){
			clds.item(i).nodeValue = " in jbidwatcher";
		}
	}
}