// ==UserScript== // @name 自动任务 // @namespace http://tampermonkey.net/ // @version 0.9.4 // @description 自动完成marvelousga,dupedornot,gamecode等网站访问网页任务,自动验证所有任务 // @author HCLonely // @include *://www.grabfreegame.com/giveaway/* // @include *://gamecode.win/giveaway/* // @include *://whosgamingnow.net/giveaway/* // @include *://marvelousga.com* // @include *://dupedornot.com* // @include *://gamezito.com* // @include *://www.bananagiveaway.com/giveaway/* // @include *://gamehag.com/giveaway/* // @include *://giveawayhopper.com/giveaway/* // @include *://giveaway.su/giveaway/view/* // @include *://gleam.io/* // @include *://gamehunt.net/distribution/* // @run-at document-end // @grant GM_addStyle // @grant GM_xmlhttpRequest // @require https://greasyfork.org/scripts/376085-httpsend/code/httpSend.js?version=658478 // @downloadURL none // ==/UserScript== (function() { 'use strict'; var autoOpen=1;//1为自动打开任务页面;改为0则不打开任务页面 if(/You need to be logged in to perform all tasks|Please login to see the tasks/gim.test(document.getElementsByTagName("body")[0].innerText)){ window.location.href="/login"; return 0; } var url=window.location.href; var bg=/bananagiveaway/gim.test(url)?"background-color:#71c61d;":""; var height=/grabfreegame/gim.test(url)?96:(/bananagiveaway/gim.test(url)?110:(/gamezito/gim.test(url)?125:(/gamecode/gim.test(url)?30:40))); var game=url.replace(/https?:\/\/(www)?(marvelousga|dupedornot|gamezito|gamecode).(com|win)\/giveaway\/|/,""); GM_addStyle(` #doTaskDiv{position:fixed;right:80px;top:${height}px;width:85px;z-index: 99999999999;} #info{max-height:352px;overflow-y:auto;padding:0 !important} #exInfo{position:fixed;right:50px;bottom:10px;max-width:600px;max-height:400px;z-index: 99999999999;display:none;background-color:#fff;padding:1.5rem} .infos{position:absolute;top:0px;left:0px;background-color:#757d81;border-radius: 3px !important;padding: 0px 2px !important;width:20px;height:20px} #shouqi{font-weight:900;color:#00e5ff} #doTask{width:145px;height:40px;${bg}} #Verify{width:145px;height:40px;${bg}} #Remove{width:145px;height:40px;${bg}} #fixed-banana,cloudflare-app{display:none !important} `); var div=document.createElement("div"); div.setAttribute("id", "doTaskDiv"); div.setAttribute("class", "card-content"); div.innerHTML=` `; var div3=document.createElement("div"); div3.setAttribute("id", "exInfo"); var div2=document.createElement("div"); div2.setAttribute("id", "info"); div2.setAttribute("class", "card-body card"); //div2.setAttribute("style", "position:fixed;right:50px;bottom:10px;max-width:600px;max-height:400px;overflow-y:auto;z-index: 99999999999;display:none"); div3.innerHTML=``; document.getElementsByTagName("body")[0].appendChild(div); div3.appendChild(div2); document.getElementsByTagName("body")[0].appendChild(div3); document.getElementById("shouqi").onclick=function(e){ e=document.getElementById("shouqi").className=="zhankai"?["20px","↖","展开","shouqi","none"]:["","↘","收起","zhankai","block"]; div3.style.width=e[0]; div3.style.height=e[0]; document.getElementById("shouqi").innerText=e[1]; document.getElementById("shouqi").setAttribute("title", e[2]); document.getElementById("shouqi").setAttribute("class", e[3]); div2.style.display=e[4]; } if(/marvelousga|dupedornot|gamezito/.test(url)){//marvelousga,dupedornot,gamezito领key if($("body").text().match(/THIS GIVEAWAY IS CLOSED FOR THE MOMENT/gim)!=null){ if(confirm("此页面已经没有key了,是否关闭?")){ window.close(); } } $('cloudflare-app[app="welcome-bar"]').remove(); var w=0; banNewBlock(); marvelousga(); //防止419 function token(){ var btn=document.getElementsByTagName("button"); for(var j=0;j${msg}!`; } e===w&&(getId()); }, error:function(jqXHR, textStatus, errorThrown){ p.innerHTML+=`${textStatus}:${jqXHR.status}-${errorThrown}`; e===w&&(getId()); } }); } //marvelousga,dupedornot,gamezito获取任务id function getId(task_id=[],api_id=[],btn_id=[],p_id=[]){ var btn=document.getElementsByTagName("button"); for(var i=0;i0&&api_id.length>0&&btn_id.length>0&&p_id.length>0){ verify(task_id,api_id,btn_id,p_id,0); }else if(task_id.length==0&&api_id.length==0&&btn_id.length==0&&p_id.length==0){ info("card-text monospace","color:green",`所有任务验证完成!`); getKey(); } } //marvelousga,dupedornot,gamezito验证任务 function verify(task_id,api_id,btn_id,p_id,e,v=0){ if(/visit[\w\W]*?webpage/gim.test(p_id[e])&&v==1){ e++; verify(task_id,api_id,btn_id,p_id,e,v); return; }else{ if(/visit[\w\W]*?webpage/gim.test(p_id[e])&&v!=1){ v=1; } var p=info("card-text monospace","",`验证任务${task_id[e]}:${p_id[e]}...`); if(/Join[\w\W]*?in Steam/i.test(p_id[e].innerText)){ document.getElementById(btn_id[e]).removeAttribute("disabled"); document.getElementById(btn_id[e]).click(); } $.ajax({ type: "post", url: "/ajax/verifyTasks/"+api_id[e], datatype: "json", data:{ giveaway_slug: game, giveaway_task_id: task_id[e] }, crossDomain:true, xhrFields: { withCredentials: true }, success: function (data) { if(data.status==1){ document.getElementById(btn_id[e]).innerText="VERIFIED"; p.innerHTML+="OK!--"+data.percentageNanoBar+"%"; }else{ document.getElementById(btn_id[e]).innerText="ERROR!"; document.getElementById(btn_id[e]).style.color="red"; /gamezito/gim.test(url)?document.getElementById(btn_id[e]).parentNode.parentNode.getElementsByTagName("a")[0].click():document.getElementById(btn_id[e]).parentNode.getElementsByTagName("a")[0].click(); var msg=data.message||"ERROR"; p.innerHTML+=`${msg}!`; } e++; if(data.percentageNanoBar==100||e>=btn_id.length){ info("card-text monospace","color:green",`所有任务验证完成!`); getKey(); }else{ verify(task_id,api_id,btn_id,p_id,e,v); } }, error:function(jqXHR, textStatus, errorThrown){ document.getElementById(btn_id[e]).innerText="ERROR!"; document.getElementById(btn_id[e]).style.color="red"; jqXHR.status!=419&&(document.getElementById(btn_id[e]).parentNode.getElementsByTagName("a")[0].click()); p.innerHTML+=`${textStatus}:${jqXHR.status}-${errorThrown}`; e++; if(e谷歌验证获取key!`); document.getElementById("google").onclick=function(){ document.getElementById("get_key_container").scrollIntoView(); document.getElementById("get_key_container").getElementsByClassName("card-body")[0].style.backgroundColor="red"; setTimeout(function(){document.getElementById("get_key_container").getElementsByClassName("card-body")[0].style.backgroundColor=""},600); }; document.getElementById("get_key_container").style.display="block"; document.getElementById("get_key_container").scrollIntoView(); document.getElementById("get_key_container").getElementsByClassName("card-body")[0].style.backgroundColor="red"; setTimeout(function(){document.getElementById("get_key_container").getElementsByClassName("card-body")[0].style.backgroundColor=""},600); } //marvelousga,dupedornot,gamezito按钮定义 function marvelousga(){ document.getElementById("doTask").onclick=function(){ document.getElementById("exInfo").style.display="block"; $('button>span:contains("Join ")').click(); $('button>span:contains("Follow ")').click(); info("card-text monospace","",`正在做加组、关注等任务(此功能需要Giveaway Helper脚本,没有则自动跳过此步骤),请稍候!`); doTask(function(){ w=0; var crsf=token(); if(crsf===1){ if($("video").length>0){ var videoDiv=$("video").parent().parent().parent().parent(); videoDiv.find("button.btn-dark")[0].id.replace(/task_video_watched_/,""); w++; finTask(videoDiv.find("button.btn-dark")[0].id.replace(/task_video_watched_/,""),"","Watch this video",0); } var a=document.getElementsByTagName("a"); var taskId,text; for(var i=0;ispan:contains("Join ")').length+$('button>span:contains("Follow ")').length)*3); }; document.getElementById("Verify").onclick=function(){ document.getElementById("exInfo").style.display="block"; var crsf=token(); crsf===1&&(getId()); }; } } //gamecode领key if(/gamecode/.test(url)){ if($("body").text().match(/THIS GIVEAWAY IS CLOSED FOR THE MOMENT/gim)!=null){ if(confirm("此页面已经没有key了,是否关闭?")){ window.close(); } } banNewBlock(); //gamecode按钮定义 document.getElementById("doTask").onclick=function(){ document.getElementById("exInfo").style.display="block"; $('button>span:contains("Join ")').click(); $('button>span:contains("Follow ")').click(); info("card-text monospace","",`正在做加组、关注等任务(此功能需要Giveaway Helper脚本,没有则自动跳过此步骤),请稍候!`); doTask(gamecode_task,new Date().getTime(),($('button>span:contains("Join ")').length+$('button>span:contains("Follow ")').length)*3); }; document.getElementById("Verify").onclick=function(){ document.getElementById("exInfo").style.display="block"; gamecode_task(); }; //gamecode做任务 function gamecode_task(){ var gamecode_btn=document.getElementsByClassName("btn btn-theme"); info("card-title","color: #f38288",`正在自动做任务,任务完成后请手动完成谷歌验证领取key!`); for(var i=0;ispan:contains("Join ")').click(); $('button>span:contains("Follow ")').click(); info("card-text monospace","",`正在做加组、关注等任务(此功能需要Giveaway Helper脚本),请稍候!`); doTask(getBtn("d"),new Date().getTime(),($('button>span:contains("Join ")').length+$('button>span:contains("Follow ")').length)*3); }; document.getElementById("Verify").onclick=function(){ document.getElementById("exInfo").style.display="block"; getBtn("v"); }; div2.setAttribute("style", `right:50px;bottom:10px;z-index: 99999999999;font-family: Menlo,Monaco,Consolas,"Courier New",monospace;font-size: 20px;background: #fff;color: #f05f00;border: 3px solid #ababab;order-radius: 8px;display: inline-block;`); //grabfreegame,bananagiveaway检测是否需要香蕉 function isBanana(){ var p=document.getElementsByTagName("p"); for (var i=0;i0&&e==="d"&&(gbDoTask(0,verify_btn,do_btn)); verify_btn.length>0&&e==="v"&&(bananaVerify(0,verify_btn)); } //grabfreegame,bananagiveaway做任务 function gbDoTask(e,verify_btn,do_btn){ var taskId=do_btn[e].match(/\?q\=[\d]+/)[0]; taskId=taskId.replace("?q=",""); var p=info("code","",`执行任务:${taskId}...`); $.ajax({ type: "get", url: do_btn[e], timeout:"10000", datatype: "json", crossDomain:true, xhrFields: { withCredentials: true }, complete: function (data) { p.innerHTML+="OK!"; e++; e0&&(bananaVerify(0,verify_btn))); } }); } //grabfreegame,bananagiveaway验证任务 function bananaVerify(e,verify_btn){ var taskId=verify_btn[e].match(/\?verify\=[\d]+/)[0]; taskId=taskId.replace("?verify=",""); var p=info("code","",`验证任务:${taskId}...`); $.ajax({ type: "get", url: verify_btn[e], timeout:"10000", datatype: "json", crossDomain:true, xhrFields: { withCredentials: true }, complete: function (data) { p.innerHTML+="OK!"; e++; espan:contains("Join ")').click(); $('button>span:contains("Follow ")').click(); doTask(wsn_enter,new Date().getTime(),($('button>span:contains("Join ")').length+$('button>span:contains("Follow ")').length)*3); }; document.getElementById("Verify").onclick=function(){ alert("请手动完成加组任务!"); document.getElementById("exInfo").style.display="block"; wsn_enter(); }; btn_class("btn btn-primary"); //wgn获取key function wsn_enter(){ $.ajax({ type: "post", url: url, datatype: "json", data:{ submit: "Enter", }, crossDomain:true, xhrFields: { withCredentials: true }, success: function (data) { if(/

Steam key:<\/h3>

[\w\d]{5}(-[\w\W]{5}){2}<\/strong><\/p>/i.test(data)){ var key=data.match(/

Steam key:<\/h3>

[\w\d]{5}(-[\w\W]{5}){2}<\/strong><\/p>/i)[0]; key=key.replace(/(

Steam key:<\/h3>

)|(<\/strong><\/p>)/gi,""); data=data.replace(key,`${key}`); } document.write(data); }, error:function(jqXHR, textStatus, errorThrown){ alert(textStatus+":"+jqXHR.status+"-"+errorThrown); } }); } } if(/gamehag/.test(url)){//gamehag领key if($("div.strong").eq(0).text()==0){ $("div.strong").eq(0).parent()[0].style.backgroundColor="red"; if(confirm("此页面已经没有key了,是否关闭?")){ window.close(); } }else if($("div.strong").eq(1).text()==0){ $("div.strong").eq(1).parent()[0].style.backgroundColor="red"; if(confirm("此领key页面已过期,是否关闭?")){ window.close(); } } var success,error,a,survey=0;; btn_class("btn btn-primary btn-sm box-collapse-verify"); $("#doTaskDiv").css({"right": "340px","top": "100px"}); $("#doTask").width("105px"); $("#Verify").width("105px"); $("#Remove").width("105px"); GM_addStyle(`.misty-notification{display:none !important}`); //gamehag按钮定义 document.getElementById("doTask").onclick=function(){ document.getElementById("exInfo").style.display="block"; $('button>span:contains("Join ")').click(); $('button>span:contains("Follow ")').click(); info("card-text monospace","",`正在做加组、关注等任务(此功能需要Giveaway Helper脚本,没有则自动跳过此步骤),请稍候!`); doTask(function(){ success=0; error=0; survey=$("a.giveaway-survey").length>0&&(/\+1/gim.test($("a.giveaway-survey").parent().parent().next().text()))?1:0; a=0; var p=info("card-text monospace","",`正在做任务...`); $("button[data-id]").length>0?gamehag_task(p):gamehag_suryey(0,p); },new Date().getTime(),($('button>span:contains("Join ")').length+$('button>span:contains("Follow ")').length)*3); }; document.getElementById("Verify").onclick=function(){ document.getElementById("exInfo").style.display="block"; success=0; error=0; survey=$("a.giveaway-survey").length>0&&(/\+1/gim.test($("a.giveaway-survey").parent().parent().next().text()))?1:0; $("button[data-id]").length>0&&($("button[data-id]").map(function(i,e){gamehag_verify(e)})); survey==1&&(gamehag_verify($("a.giveaway-survey")[0],"data-task_id")); }; //开始执行 function gamehag_task(p){ $("button[data-id]").map(function(i,e){ $.ajax({ url:'https://gamehag.com/giveaway/click/'+$(e).attr("data-id"), type:'get', headers:{'x-csrf-token': $('meta[name="csrf-token"]').attr('content')}, complete:function(){ a++; a==$("button[data-id]").length&&($.ajax({url:'https://gamehag.com/games/war-thunder/play',type:'get',headers:{'x-csrf-token': $('meta[name="csrf-token"]').attr('content')},complete:function(){gamehag_start(p)}})); } }); }); } //开始执行 function gamehag_start(p){ p.innerHTML+=`OK!`; gamehag_suryey(); $("button[data-id]").map(function(i,e){gamehag_verify(e)}); } //gamehag问卷调查任务 function gamehag_suryey(e=1,p=0){ p!=0&&(p.innerHTML+=`OK!`); if(survey==1){ info("card-text monospace","",`正在做问卷调查任务,如果没有此任务请忽视!`); jQuery.ajax({url:'https://gamehag.com/giveaway/click/'+$("a.giveaway-survey").attr("data-task_id"),type:'get',headers:{'x-csrf-token': $('meta[name="csrf-token"]').attr('content')}}); gamehag_verify($("a.giveaway-survey")[0],"data-task_id"); }else if(e==0){ info("","color:green",`所有任务验证完成,请手动完成验证领取key!`); } } //gamehag验证任务 function gamehag_verify(e,s="data-id"){ if(/\+1/gim.test($(e).parent().parent().next().text())){ var p=info("card-text monospace","",`验证任务:${$(e).parent().parent().find("a.tooltip-trigger").clone().html()}...`); $.ajax({ url:'https://gamehag.com/api/v1/giveaway/sendtask', type:'post', data:'task_id='+$(e).attr(s), headers:{'x-csrf-token': $('meta[name="csrf-token"]').attr('content')}, complete:function(XMLHttpRequest, textStatus){ if(XMLHttpRequest.status==429||/timeout/gim.test(textStatus)){ $(p).remove(); gamehag_verify(e); }else{ var data=eval('('+XMLHttpRequest.responseText+')'); data.status=="success"?success++:error++; var color=data.status=="success"?"green":"red"; p.innerHTML+=`${data.message}!`; data.status=="success"&&($(e).parent().parent().parent().find("div.task-reward.tooltip-trigger").html(``)); if(/The task has not been completed/gim.test(data.message)&&autoOpen==1){ window.open('https://gamehag.com/giveaway/click/'+$(e).attr("data-id"),"_blank"); } } if(success+error==$("button[data-id]").length+survey){ if(error>0){ info("","color:red",`所有任务验证完成,${error}个任务验证失败!`); }else{ info("","color:green",`所有任务验证完成,请手动完成验证领取key!`); } btn_class("btn btn-primary btn-sm box-collapse-verify"); } } }); }else{ success++; if(success+error==$("button[data-id]").length+$("a.giveaway-survey").length){ if(error>0){ info("","color:red",`所有任务验证完成,${error}个任务验证失败!`); }else{ info("","color:green",`所有任务验证完成,请手动完成验证领取key!`); } btn_class("btn btn-primary btn-sm box-collapse-verify"); } } } } if(/giveawayhopper/.test(url)){//giveawayhopper领key btn_class("btn btn-outline-primary"); //giveawayhopper按钮定义 document.getElementById("doTask").onclick=function(){ alert("点击确定后页面可能会卡一段时间,属于正常现象!"); $('button>span:contains("Join ")').click(); $('button>span:contains("Follow ")').click(); doTask(function(){ var ghBtn=$(".task-item-btn-verify"); for(var i=0;ispan:contains("Join ")').length+$('button>span:contains("Follow ")').length)*3); }; document.getElementById("Verify").onclick=function(){ alert("点击确定后页面可能会卡一段时间,属于正常现象!"); var ghBtn=$(".task-item-btn-verify"); for(var i=0;i0){ if(confirm("此页面已经没有key了,是否关闭?")){ window.close(); } } btn_class("btn btn-success btn-sm"); //giveaway.su按钮定义 document.getElementById("doTask").onclick=function(){ if($("a.pull-right").length>0&&$("a.pull-right").parent().parent()[0].className!="hidden"){ $("a.pull-right")[0].click(); return false; } $('tr[data-action-id="adjs"]').remove(); $('a[data-type="link"]').attr("href","javascript:void(0)"); $('a[data-type="link"]').find("i").click(); $("a.btn-success").removeClass("disabled"); $('button>span:contains("Join ")').click(); $('button>span:contains("Follow ")').click(); doTask(function(){giveaway_su_verify($("i.glyphicon-refresh"),0)},new Date().getTime(),($('button>span:contains("Join ")').length+$('button>span:contains("Follow ")').length)*3); }; document.getElementById("Verify").onclick=function(){ $('tr[data-action-id="adjs"]').remove(); $('a[data-type="link"]').attr("href","javascript:void(0)"); $('a[data-type="link"]').find("i").click(); $("a.btn-success").removeClass("disabled"); giveaway_su_verify($("i.glyphicon-refresh"),0); }; function giveaway_su_verify(vBtn,i){ if(vBtn.length==0){ $("a.btn-success").click(); }else{ if(!/glyphicon-ok/gim.test(vBtn[i].className)){ vBtn.eq(i).parent().attr("disabled"); vBtn.eq(i).parent().removeAttr("disabled"); vBtn.eq(i).parent().click(); } i++; setTimeout(function(){ispan:contains("Join ")').click(); $('button>span:contains("Follow ")').click(); doTask(function(){ gleam_do_task($("a.enter-link"),0); },new Date().getTime(),($('button>span:contains("Join ")').length+$('button>span:contains("Follow ")').length)*3); }; document.getElementById("Verify").onclick=function(){ gleam_do_task($("a.enter-link"),0); }; function gleam_do_task(a,i){ if(i0){ window.open("https://www.hclonely.cn/time.html?time="+time,"_blank"); var hidden=setInterval(function(){ if(!document.hidden){ clearInterval(hidden); setTimeout(function(){ b[0].click(); i++; gleam_do_task(a,i); },1000); } },1000); }else{ b[0].click(); i++; gleam_do_task(a,i); } } } if(/gamehunt/.test(url)){//gamehunt领key if($("a.nav-link.btn-outline-secondary").length>0){ location.href="/auth/vkontakte"; } btn_class("btn btn-outline-secondary btn-sm") //gamehunt按钮定义 document.getElementById("doTask").onclick=gamehunt; document.getElementById("Verify").onclick=gamehunt; function gamehunt(){ document.getElementById("exInfo").style.display="block"; info("","","此功能与点击get key按钮相同!"); httpSend({ mode:"jq", url:"https://gamehunt.net/end/distribution", type:"post", timeout:15000, data:{id:location.href.match(/[\d]+/gim)[0]}, callback:function(data){ if(data.status==200){ if(data.json.err=="err"&&data.json.res.length>0){ data.json.res.map(function(e){ $("#"+e).css("background-color","red"); autoOpen=1&&(window.open($("#"+e).attr("href"),"_blank")); }); }else if(data.json.err=="err01"){ info("","color:red","I thought about it and I will not give you a key, since you already received it!"); }else{ info("","color:red","未知错误码:"+data.json.err); document.getElementById("go_geme").click(); } } } }); } } //if(/https?:\/\/www.chubbykeys.com\/[\w\W]*/.test(url)){//chubbykeys领key /* if($("button.btn-lg.hvr-grow-rotate").length>0){ location.href="?login"; } btn_class("btn btn-outline-primary") //chubbykeys按钮定义 document.getElementById("doTask").onclick=function(){ $('button>span:contains("Join ")').click(); $('button>span:contains("Follow ")').click(); doTask(function(){ },new Date().getTime(),($('button>span:contains("Join ")').length+$('button>span:contains("Follow ")').length)*3); }; document.getElementById("Verify").onclick=function(){ }; } */ //做加组、关注等任务 function doTask(callback,time,limitTime){ $('button>span:contains("Join ")').length+$('button>span:contains("Follow ")').length==0||new Date().getTime()-time>limitTime*1000?callback():setTimeout(function(){doTask(callback,time,limitTime)},300); } //做退组、取关等任务 document.getElementById("Remove").onclick=function(){ document.getElementById("exInfo").style.display="block"; info("","",`正在退组、取关,请稍候!`); $('button>span:contains("Leave ")').click(); $('button>span:contains("Unfollow ")').click(); }; //显示信息 function info(cText,sText,iText){ var p=document.createElement("p"); p.setAttribute("class", cText); p.setAttribute("style", sText); p.innerHTML=iText; div2.appendChild(p); p.scrollIntoView(); return p; } //button样式 function btn_class(e){ var task_btn=document.getElementsByClassName("auto-task"); for(var tb=0;tb