Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
steam-calculator , 获取 steam 消费总金额
/**
* 获取 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