本来打算上个月发的,一直没管博客,不管是啥来凑个文章数吧,刚学js仿照别人的脚本改写的签到脚本
顺便说一下,写脚本真的很有趣,更有趣的是打开网页的时候Greasemonkey可以运行自己写的脚本,就酱紫
凑字数完毕→_→
哦,情人节!!!
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
var showInformation = function (text) { document.getElementById("q").value = text; };
if (document.getElementsByClassName("bigger").length){ var userId = document.getElementsByClassName("bigger")[0].textContent; }else{ var userId = 0; }
if ((new Date().getUTCDate() != GM_getValue("sign", "25:name").split(":")[0] || userId != GM_getValue("sign", "25:name").split(":")[1]) && userId ){ showInformation("正在检测每日签到状态..."); GM_xmlhttpRequest({ "method" : "GET", "url" : "/mission/daily", "onload" : function(response){ if (response.responseText.match("领取 X 铜币")){ var days = response.responseText.match(/已连续登录.+天/)[0]; showInformation("正在领取今日签到奖励"); GM_xmlhttpRequest({ "method" : "GET", "url" : response.responseText.match(/(?=\/).+?(?=\')/g)[1], "onload" : function (resp) { showInformation("正在提交"); days = "已连续登陆" + (parseInt(days.slice(5,-1)) + 1) + "天"; GM_xmlhttpRequest({ "method" : "GET", "url" : "/balance", "onload" : function(res){ function p(s) {return s<10 ? "0"+s :s; } var today = new Date().getUTCFullYear() + p(new Date().getUTCMonth()+1) +p(new Date().getUTCDate()); if (res.responseText.match(today + " 的每日登录奖励")){ showInformation(days + ",本次领取到" + res.responseText.match(eval("/"+today+".+铜币/"))[0].split("奖励")[1].replace(/ /g, "")); GM_setValue("sign", new Date().getUTCDate() + ":" + userId); }else{ showInformation("自动领取遇到意外,你可以手动领取试试") } } }) }, "onerror" : function () { showInformation("网络异常");} } ) }else{ if (response.responseText.match("已领取").length){ showInformation("今日已经领取过了"); GM_setValue("sign", new Date().getUTCDate() + ":" + userId); }else{ showInformation("无法找到领奖按钮,请检查"); } } }, "onerror" : function(){showInformation("签到页面无法打开,请手动领取");} }); }
|