Last active
December 18, 2015 02:39
-
-
Save keisuke-kawamura/5713008 to your computer and use it in GitHub Desktop.
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
(function(){ | |
function number_format(num){ | |
return num.toString().replace(/([\d]+?)(?=(?:\d{3})+$)/g, function(t){ return t + ','; }); | |
} | |
function sum_history(){ | |
var elements = document.getElementsByClassName('itemPriceAmount'); | |
var total = 0; | |
for(var i=0; i<elements.length; i++){ | |
var price_str = elements[i].innerHTML; | |
price_str = price_str.replace(/\,/,''); | |
var price = parseInt(price_str); | |
total += price | |
} | |
alert("このページに表示されている購入履歴の合計は "+ number_format(total) +" 円です。"); | |
} | |
sum_history(); | |
} | |
)(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment