amazon.de - Mehrwertsteuer für Österreich

Ändert die Preise auf amazon.de auf die österreichische Mehrwertsteuer

// ==UserScript==
// @name             amazon.de - Mehrwertsteuer für Österreich
// @name:de          amazon.de - Mehrwertsteuer für Österreich
// @name:en          amazon.de - Mehrwertsteuer (VAT) for Austria
// @version          1.4
// @namespace        http://alphabeter.at/greasemonkey/
// @description      Ändert die Preise auf amazon.de auf die österreichische Mehrwertsteuer
// @description:de   Ändert die Preise auf amazon.de auf die österreichische Mehrwertsteuer
// @description:en   Calculates the correct Austrian tax (VAT) on amazon.de
// @grant            none
// @run-at           document-idle
// @include          *://*.amazon.de/*
// @include          *://amazon.de/*
// @exclude          */buy/*
// @icon             data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAPXUlEQVR42tVbC3BU5RXe6XQ6nU47nU6n08FXgCACAiIGtSoFxEc2QSiP8MjuRqAWoeqoRKQpxMjuJoIVx4JAASki74egBawGeQjYEQRE0kB4hxDkLeFh9r2n5zv33s3dzd7du0kI9M78A7O59//Pd/7z/s9vsTTR07Nn0Y97Di/6ad+RU37RP6/k10/ai1tk5brTsvJK2mbmFXfOcrgzrE+XPJydV9wry178uNVWbNUP/Ia/4R28K9/wt5gDc2FOzI01sJblZniKiop+lJNT9JOeOUU/z85941d98ty3Woe40rMdxR2tNveDAsjhfirT4Rya5XAOt9qco7Mdrhey7K6Xs2yucVGDf8Pf8A7exTf4VubAXJiT58YaWAtrYm3QcEOBY2eeGOq+vc/wknZP5rrvB8GZNnd/q92ZJ2AdrgKrw+VmkG/zeJf/P5t/m2+1uxbwWKiOBfIb/sbv4F35hr8VpvBcmBNzYw2shTWxdrMzAuLXp0/Rz2KBQ4Sz7M7Byg66CnhH3wQgHciGDTCF5xJGYm5eA2vFMgI0XVfVAIehf4+NmvxL0W/oJ+tqBLjdNSbT7ipigqfFgiietuqzVev+s/OTTbv3Hjtx5kyigXfwLr6Jw4xpsgavpTFCaGBaQBNoA41NLg36XYdRgo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iLk5hDvS+oXNlx5mItxT0Xd9R2vUn0PVVpkGoSGxu5kaEyQg2hB0v2ZXONE4+Ba7PYPdVzJBp4R97lb9RvxymZHM/Jc2vAsaZc5VMvVN+wO8QaI2B4IldpcdZgL+kOq6xepx0pMYRyBFcgNoNFGQAFpFzK4N+Ue8b58i6+4W8xB+bCnNpVWax1Q4EbXaaG8YEeitvUXZ2XLnRkY8jHcZschgtd6XL9lRnE/1eMGcft8k5JD7Evuiv0mBNzY42mvCz9P+EKqMA7wOyRAAAAAElFTkSuQmCC
// ==/UserScript==



(function () {	

//elements, that get searched for prices: (small hack: sometimes there are two prices in <span>)
var amazonPriceElements = new Array("td", "font", "b", "span", "span");	

//VAT in percent
var mwst_de = 19;
var mwst_at = 20;
//different VAT in percent for books
var mwst_buch_de = 7;
var mwst_buch_at = 10;


//------------------------------------------------------

mwst_de = 1 + mwst_de/100.0;
mwst_at = 1 + mwst_at/100.0;
mwst_buch_de = 1 + mwst_buch_de/100.0;
mwst_buch_at = 1 + mwst_buch_at/100.0;

//search every element, where amazon shows its prices (usually <span> or <td>)
for (j = 0; j < amazonPriceElements.length; j++) 
{
	var possiblePriceElements = document.getElementsByTagName(amazonPriceElements[j]);
	for (i = 0; i < possiblePriceElements.length; i++) 
	{		
		var thisElement = possiblePriceElements[i];
		var thisHTML = thisElement.innerHTML;
		
		//search small nodes for prices
		if (thisHTML.length < 200 && thisHTML.indexOf('EUR')!= -1) 
		{
			thisHTML=thisHTML.replace("\n"," ").replace("\r"," ");
			var priceRegEx = /(.*)EUR\s*([0-9,.]+)(.*)/;
  			priceRegEx.exec(thisHTML);
  			
  			preHTML  = RegExp.$1;
  			postHTML = RegExp.$3;  			
  			oldPrice = RegExp.$2;
  			
  			//replace decimal point and 1000-sign
  			//convert to number  			
			oldPrice=parseFloat(oldPrice.replace(".","").replace(",","."));			
			
			if (isNaN(oldPrice)) continue;
			
      // calculate prices    
			newPrice1 = oldPrice / mwst_de * mwst_at;			
			newPrice1 = newPrice1.toFixed(2).replace(".",",");			
			newPrice2 = oldPrice / mwst_buch_de * mwst_buch_at;
			newPrice2 = newPrice2.toFixed(2).replace(".",",");
						
			thisElement.innerHTML=preHTML + "<span>&euro;"+newPrice1 + '</span><span style="color:#611;"> [Buch &euro;'+newPrice2 + "]</span>" +postHTML;
  		}
	}
}
})();