Skip to content

Instantly share code, notes, and snippets.

@theseanstewart
Created October 16, 2016 17:13
Show Gist options
  • Save theseanstewart/afa4fc88e1dcd269995b4c6bf5c14e66 to your computer and use it in GitHub Desktop.
Save theseanstewart/afa4fc88e1dcd269995b4c6bf5c14e66 to your computer and use it in GitHub Desktop.
Bookmarklet to show the monthly pricing for AWS next to the price per hour
javascript: (function(){
var selectors = [
'tr.tiers > td.price',
'tr.sizes > td.rate'
];
for(var s = 0, len = selectors.length; s < len; s++){
var prices = document.querySelectorAll(selectors[s]);
handlePrices(prices);
}
function handlePrices(prices){
for(var i = 0, len = prices.length; i < len; i++){
var price = cleanPrice(prices[i].innerHTML);
var pricePerHour = parseFloat(price.replace('$',''));
var pricePerMonth = pricePerHour * 24 * 30;
prices[i].innerHTML = price + " <strong>($" + pricePerMonth.toFixed(2) + "/month)</strong>";
}
}
function cleanPrice(price){
var price = price + ''; /* Convert to string */
var price = price.replace(' per Hour', '');
return price;
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment