Last active
April 13, 2017 15:53
-
-
Save hxgdzyuyi/35aeb33569f6273c91331c90f77165cd to your computer and use it in GitHub Desktop.
steam-calculator , 获取 steam 消费总金额
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
/** | |
* 获取 steam 消费总金额 | |
* 打开 https://store.steampowered.com/account/history/ 贴入 console 运行 | |
* XXX: 不支持卡片交易之类生成的金额,且当前显示金额为人民币 | |
* 截止 2017/4/13 日,消费约 3526.44 元 | |
*/ | |
var total = 0 | |
, USD_EXCHANGE_RATE = 6 | |
jQuery('.wht_total').each(function(){ | |
var el = jQuery(this) | |
, text = el.text() | |
, numberMatched = text.trim().match(/\d+(\.\d+)?/) | |
if(!numberMatched) { return } | |
var number = +numberMatched[0] | |
if(/USD/.test(text)) { | |
number = number * USD_EXCHANGE_RATE | |
} | |
total += (el.hasClass('wht_refunded') ? -1 : 1) * number | |
}) | |
console.log('消费总计约为:') | |
console.log(total) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment