Skip to content

Instantly share code, notes, and snippets.

@kkawamura
Last active December 18, 2015 02:39
Show Gist options
  • Save kkawamura/5713008 to your computer and use it in GitHub Desktop.
Save kkawamura/5713008 to your computer and use it in GitHub Desktop.
(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