Created
November 23, 2017 12:47
-
-
Save wmh/e11a62daba98e56d4b350a3bd549e4ac to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// 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