Amazon Price Watch

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

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.
// @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];
	GM_registerMenuCommand("Patch Watch",pricewatch,'e','control alt','p');
	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","");
	email=window.prompt("Please confirm your email address:",email);
	if(email.indexOf("@")<0||email.indexOf(".")<0){
		alert("Your email address is not correct.");
	}else{   
		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){
			var response = confirm('Do you want to watch the price for this item?');
			if(response){
				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>";
	}
}