Skip to content

Instantly share code, notes, and snippets.

@scintill
Created January 7, 2012 08:22
Show Gist options
  • Save scintill/1574186 to your computer and use it in GitHub Desktop.
Save scintill/1574186 to your computer and use it in GitHub Desktop.
Amazon Bitcoins
// ==UserScript==
// @name Amazon Bitcoins
// @namespace joeyhewitt
// @description Show prices on Amazon in Bitcoin
// @match http://www.amazon.com/*
// @match https://www.amazon.com/*
// ==/UserScript==
// https://gist.github.com/437513
(function(callback) {
var script = document.createElement("script");
script.textContent = "(" + callback.toString() + ")(jQuery);";
document.body.appendChild(script);
})(function($) {
var BTCPerUSD = 6.59;
var convertUSD = function(text) {
return text.replace(/\$\d+(\.\d\d)?/g, function(USD) {
return (parseFloat(USD.substring(1)) / BTCPerUSD).toFixed(2)+ ' BTC';
});
};
$('.t14, .price, .priceLarge, .listprice, .tmm_olpLinks>a, #actualPriceExtraMessaging, .fionaBuyBox font, .t11, .mbcPriceCell, .plusShippingText').each(function() {
var $priceEl = $(this);
var originalPriceText = $priceEl.text();
var btcPriceText = convertUSD(originalPriceText);
$priceEl.hover( function() { $(this).text(originalPriceText); },
function() { $(this).text(btcPriceText) } );
$priceEl.text(btcPriceText);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment