Created
October 16, 2016 17:13
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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