Skip to content

Instantly share code, notes, and snippets.

@wmh
Created November 23, 2017 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wmh/e11a62daba98e56d4b350a3bd549e4ac to your computer and use it in GitHub Desktop.
Save wmh/e11a62daba98e56d4b350a3bd549e4ac to your computer and use it in GitHub Desktop.
// https://www.esunbank.com.tw/bank/Layouts/esunbank/Accessibility/rate_exchange.aspx
var trs = document.querySelectorAll('table.inteTable tr')
for (var i = 0; i < trs.length; ++i) {
var buyPrice = trs[i].querySelector('td:nth-child(2)'),
selPrice = trs[i].querySelector('td:nth-child(3)');
if (buyPrice == null || isNaN(buyPrice.innerText) || selPrice == null || isNaN(selPrice.innerText)) {
continue;
}
console.log(1);
var buyPriceFloat = parseFloat(buyPrice.innerText),
selPriceFloat = parseFloat(selPrice.innerText),
diff = Math.round((selPriceFloat - buyPriceFloat) / selPriceFloat * 10000) / 100;
selPrice.innerText = selPrice.innerText + ' (' + diff + '%)';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment