-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
52 lines (41 loc) · 1.02 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
var repeater;
function getData()
{
var data = {
tbs:PageData.tbs || "0",
fr:PageData.product || "frs",
forum_id:PageData.forum.id || 0,
ie:"utf8"
}
$.post("tbscore/timebeat",data, postData);
}
function postData(dataObj)
{
//set post data
if(dataObj == null || !("data" in dataObj && "gift_info" in dataObj.data))
return;
var giftInfo = dataObj.data.gift_info;
for(var i = 0 ; i < giftInfo.length; ++i)
{
var info = giftInfo[i];
var data =
{
tbs:PageData.tbs || "0",
fr:PageData.product || "frs",
forum_id:PageData.forum.id || 0,
ie:"utf8",
type:info.gift_type == 1 ? "time" : "rand",
gift_key:info.gift_key
}
$.post("http://tieba.baidu.com/tbscore/opengift",data, getPostAnswer);
}
console.log("再来");
repeater = setTimeout("getData()",1000);
}
function getPostAnswer(responsedData)
{
if(responsedData.no == 0)
document.write("捡到一个" + responsedData.data.gift_got.gift_score + "的蛋...<br/>");
}
document.body.innerHTML = "";
repeater = setTimeout("getData()",10000);