Skip to content

Instantly share code, notes, and snippets.

@hxgdzyuyi
Last active April 13, 2017 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hxgdzyuyi/35aeb33569f6273c91331c90f77165cd to your computer and use it in GitHub Desktop.
Save hxgdzyuyi/35aeb33569f6273c91331c90f77165cd to your computer and use it in GitHub Desktop.
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