Skip to content

Instantly share code, notes, and snippets.

@17
Created November 17, 2014 13:45
Show Gist options
  • Save 17/cdd032803a1ccf44e291 to your computer and use it in GitHub Desktop.
Save 17/cdd032803a1ccf44e291 to your computer and use it in GitHub Desktop.
bilibili miner!
var miner = function() {
var postData, timeoutID, startLoop, stopLoop, printList
var list = []
startLoop = function(delay) {
console.log('开始了辛勤的挖掘.')
timeoutID = setInterval(postData, delay || 1000 * 10)
}
stopLoop = function() {
clearTimeout(timeoutID)
console.log('工作结束了 ( ゜- ゜)つロ 乾杯~ ')
}
printList = function() {
console.table(list)
console.log('挖了那么多, 酬劳一下? (●°u°●)​つ')
}
postData = function () {
$.ajax({
url: "http://www.bilibili.com/widget/ajaxGetGift",
dataType: "json",
type: "post",
data: {
gift_id: 22,
act: "get_code"
},
success: function(data) {
if (data.code == 0) {
list.push({
item: data.item,
card: data.card
})
console.info('发现了' + data.item)
} else if (data.code == -7) {
console.warn('可恶的验证马挡住了前面的去路!')
stopLoop()
} else {
console.error('好像出现了点什么错误: ' + data.msg)
stopLoop()
}
},
error: function() {
console.info('网络不给力啊..')
}
})
}
return {
play: startLoop,
stop: stopLoop,
list: printList
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment