Amazon Price Watch

By NukePrice.com Last update Oct 16, 2009 — Installed 1,224 times. Daily Installs: 4, 0, 0, 0, 3, 0, 1, 1, 0, 0, 1, 1, 2, 0, 1, 0, 1, 4, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0

There are 4 previous versions of this script.

// ==UserScript==
// @name           Amazon Price Watch
// @namespace      http://www.nukeprice.com
// @description    Amazon Price Watch is a great tool to save money on Amazon.com through refunds. This is an advance version which will watch price automatically. For regular version, check: http://userscripts.org/scripts/show/12677
// @include        http://www.amazon.com/*
// @include        http://www.amazon.co.uk/*
// @include        http://www.amazon.co.jp/*
// @include        http://www.amazon.de/*
// @include        http://www.amazon.fr/*
// @include        http://www.amazon.ca/*
// @include        http://amazon.com/*
// @include        http://amazon.co.uk/*
// @include        http://amazon.ca/*
// @include        http://amazon.co.jp/*
// @include        http://amazon.fr/*
// @include        http://amazon.de/*
// ==/UserScript==

//don't do anything for image pages
if(window.location.href.indexOf("images/")>=0)
	return;
var marketplace=0;
if(window.location.href.indexOf("amazon.co.uk")>=0)
	marketplace=1;
if(window.location.href.indexOf("amazon.ca")>=0)
	marketplace=2;
if(window.location.href.indexOf("amazon.de")>=0)
	marketplace=3;
if(window.location.href.indexOf("amazon.co.jp")>=0)
	marketplace=4;
if(window.location.href.indexOf("amazon.fr")>=0)
	marketplace=5;
var regex=/\/([A-Z0-9]{10})(\/|$|\?)/;
var asin="";
var isDetailPage=false;
if(regex.test(window.location.href)){
	isDetailPage=true;
	var m=regex.exec(window.location.href);
	asin=m[1];
	var lastasin=GM_getValue("NukePriceLastASIN","");
	if(lastasin.indexOf(asin)<0){
		lastasin=asin+lastasin;
		if(lastasin.length>100)
			lastasin=lastasin.substring(0,100);
		GM_setValue("NukePriceLastASIN",lastasin);
		//prepare price watch
		window.location.href='http://www.nukeprice.com/pw/pw.aspx?asin='+asin+'&SetReady=true&Source=fxscript&marketplace='+marketplace;
	}
}

function pricewatch(){
	var email=GM_getValue("NukePriceEmail","");
	if(email.indexOf("@")<0||email.indexOf(".")<0){
		email=window.prompt("Please input your email address (to modify your email address, you need to clear private data):",email);
		GM_setValue("NukePriceEmail",email);
	}
	GM_openInTab('http://www.nukeprice.com/pw/pw.aspx?asin='+asin+'&email='+email+'&marketplace='+marketplace);
}

function newsubmit(event) {
	if(isDetailPage){
		var m=regex.exec(window.location.href);
		var target = event ? event.target : this;
		if(target.action.indexOf("handle-buy-box")>=0){
			pricewatch();
		}
	}
}
if(isDetailPage){
	window.addEventListener('submit', newsubmit, false);
}

// filler items
var doc = document.evaluate("//tr/td/span[@class='small']/b/span[@class='price']", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
var thresholdPrice=6;
if(doc.snapshotItem(0)){
    var price = doc.snapshotItem(0).innerHTML.substring(1);
    var node = doc.snapshotItem(0).parentNode.parentNode.parentNode;
	if(parseFloat(price) < thresholdPrice){
		node.innerHTML += "<font color=red><br/><b><a href=\"http://nukeprice.com/onlinetools.html\">Find filler item</a> to get free shipping!</b></font>";
	}
}

doc = document.evaluate("//tr/td/span[@class='sans']/b", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
if(doc.snapshotItem(1) && doc.snapshotItem(1).innerHTML.indexOf(" Super Saver ")>0){ 
	var price = doc.snapshotItem(0).innerHTML.substring(1);
	var node = doc.snapshotItem(0).parentNode.parentNode;
	if(parseFloat(price) < thresholdPrice){
		node.innerHTML += "<font size=+1 color=red><br/><b><a href=\"http://nukeprice.com/onlinetools.html\">Find filler item</a> to get free shipping!</b></font>";
	}
}