自动任务

try to take over the world!

Per 06-08-2018. Zie de nieuwste versie.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey, Greasemonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Userscripts.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een gebruikersscriptbeheerder nodig.

(Ik heb al een user script manager, laat me het downloaden!)

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

(Ik heb al een beheerder - laat me doorgaan met de installatie!)

// ==UserScript==
// @name         自动任务
// @namespace    http://tampermonkey.net/
// @version      0.6.1
// @description  try to take over the world!
// @author       HCLonely
// @include      *://marvelousga.com/giveaway/*
// @include      *://dupedornot.com/giveaway/*
// @include      *://gamezito.com/giveaway/*
// @include      *://www.grabfreegame.com/giveaway/*
// @include      *://gamecode.win/giveaway/*
// @include      *://whosgamingnow.net/giveaway/*
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';
    if(/You need to be logged in to perform all tasks/gim.test(document.getElementsByTagName("body")[0].innerText)){
        window.location.href="/login";
        return 0;
    }

    var url=window.location.href;
    var t=0;
    var addUrl="//store.steampowered.com/api/addtowishlist";
    var removeUrl="//store.steampowered.com/api/removefromwishlist";
    var game=url.replace("https://marvelousga.com/giveaway/","");
    game=game.replace("https://dupedornot.com/giveaway/","");
    game=game.replace("https://gamezito.com/giveaway/","");
    game=game.replace("https://www.grabfreegame.com/giveaway/","");
    game=game.replace("https://gamecode.win/giveaway/","");
    var div=document.createElement("div");
    div.setAttribute("id", "doTaskDiv");
    div.setAttribute("style", "position:fixed;right:80px;top:120px;width:85px;z-index: 99999999999;");
    div.innerHTML=`<button id="doTask" class="btn btn-round auto-task" style="width:145px;height:40px;background-color:blue">FuckTask</button>
<button id="Verify" class="btn btn-round auto-task" style="width:145px;height:40px;background-color:blue">Verify</button>
<button id="removeWishlist" class="btn btn-round auto-task" style="width:145px;height:40px;background-color:blue">removeWishlist</button>`;
    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;");
    document.getElementsByTagName("body")[0].appendChild(div);
    document.getElementsByTagName("body")[0].appendChild(div2);

    //防止弹出新窗口
    document.cookie = "haveVisited=1; path=/";
    var d = new Date();
    var value = readCookie('lastVisit');
    var lastVisit = new Date(value);
    var todayStr = (d.getUTCMonth() + 1) +"/"+ d.getUTCDate() + "/" + d.getUTCFullYear();
    var today = new Date(todayStr);
    var timeDiff = Math.abs(today.getTime() - lastVisit.getTime());
    var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
    document.cookie = "lastVisit="+(d.getUTCMonth()+1)+"/"+ d.getUTCDate() + "/" + d.getUTCFullYear() + "; path=/";
    function readCookie(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for(var i=0;i < ca.length;i++) {
            var c = ca[i];
            while (c.charAt(0)==' ') c = c.substring(1,c.length);
            if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
        }
        return null;
    }



    if(/https?:\/\/(marvelousga|dupedornot|gamezito).com\/giveaway\/[\w\W]*/.test(url)){
        document.getElementById("doTask").onclick=function(){
            t=0;
            var crsf=token();
            if(crsf===1){
                var a=document.getElementsByTagName("a");
                for(var i=0;i<a.length;i++){
                    var parent=a[i].parentNode.parentNode;
                    if(a[i].innerText==="this"&&/task_webpage_clickedLink_[\d]*/.test(a[i].id)&&!/verified/i.test(parent.getElementsByTagName("button")[0].innerText)){
                        var taskId=a[i].id.replace("task_webpage_clickedLink_","");
                        var text=a[i].parentNode.innerHTML.replace(/id\=\"[\w\W]*?\"/i,"");
                        t++;
                        webpage(taskId,t,text);
                    }
                    //if(/Wishlist/i.test(parent)&&/https?:\/\/store.steampowered.com\/app\/[\w\W]*/i.test(a[i].href)){
                    /*
                var app=a[i].href.match(/[\d]+/)[0];
                wondow.open("https://store.steampowered.com/api/addtowishlist#"+app,"_blank");
            }
            */
                }
                if(t==0){
                    getId();
                }
            }
        };
        document.getElementById("Verify").onclick=function(){
            task_id=[];
            api_id=[];
            btn_id=[];
            p_id=[]
            getId();
        };
        function token(){
            var a=document.getElementsByTagName("a");
            for(var j=0;j<a.length;j++){
                if(a[j].innerText==="this"&&/task_webpage_clickedLink_[\d]*/.test(a[j].id)){
                    a[j].href="javascript:void(0)";
                    a[j].click();
                    return 1;
                }
            }
        }
        function google_verify(){
            var a=document.getElementsByTagName("button");
            for(var j=0;j<a.length;j++){
                if(/(verify|verified)/i.test(a[j].innerText)&&/task_[\w\W]*[\d]*/i.test(a[j].id)){
                    a[j].href="javascript:void(0)";
                    a[j].click();
                    return 1;
                }
            }
        }
        function webpage(taskId,e,text){
            var p=document.createElement("p");
            p.setAttribute("class", "card-text monospace");
            p.innerHTML=`开始任务${taskId}:${text}...`;
            div2.appendChild(p);
            p.scrollIntoView();
            //console.log(e);
            $.ajax({
                type: "post",
                url: "/ajax/verifyTasks/webpage/clickedLink",
                datatype: "json",
                data:{
                    giveaway_slug: game,
                    giveaway_task_id: taskId
                },
                crossDomain:true,
                xhrFields: {
                    withCredentials: true
                },
                success: function (data) {
                    if(data.status==1){
                        document.getElementById("task_webpage_visit_"+taskId).innerText="OK";
                        p.innerHTML+="<font style='color:green'>OK!</font>";
                    }else{
                        var msg=data.message||"ERROR";
                        p.innerHTML+=`<font style='color:red'>${msg}!</font>`;
                    }
                    if(e===t){
                        //console.log("ok");
                        getId();
                    }
                },
                error:function(jqXHR, textStatus, errorThrown){
                    p.innerHTML+=`<font style='color:red'>${textStatus}:${jqXHR.status}-${errorThrown}</font>`;
                    if(e===t){
                        //console.log("ok");
                        getId();
                    }
                }
            });
        }
        /*
    document.getElementById("removeWishlist").onclick=function(){
        var a=document.getElementsByTagName("a");
        for(var i=0;i<a.length;i++){
            var parent=a[i].parentNode.parentNode;
            */
        //if(/Wishlist/i.test(parent)&&/https?:\/\/store.steampowered.com\/app\/[\w\W]*/i.test(a[i].href)){
        /*   var app=a[i].href.match(/[\d]+/)[0];
                wondow.open("https://store.steampowered.com/api/addtowishlist#"+app,"_blank");
            }
        }
    }*/
        var task_id=[];
        var api_id=[];
        var btn_id=[];
        var p_id=[]
        function getId(){
            var btn=document.getElementsByTagName("button");
            for(var i=0;i<btn.length;i++){
                var btnId=btn[i].id;
                if(/task_[\w\W]*[\d]*/i.test(btnId)&&!/verified/i.test(btn[i].innerText)){
                    var tskid=btnId.replace("task_","");
                    tskid=tskid.replace(/_[\d]+/,"");
                    tskid=tskid.replace("_","/");
                    api_id.push(tskid);
                    //console.log(btnId);
                    task_id.push(btn[i].id.match(/[\d]+/)[0]);
                    btn_id.push(btnId);
                    if(/https?:\/\/gamezito.com\/giveaway\/[\w\W]*/.test(url)){
                        p_id.push(btn[i].parentNode.parentNode.getElementsByTagName("h3")[0].innerHTML.replace(/id\=\"[\w\W]*?\"/i,""));
                    }else{
                        p_id.push(btn[i].parentNode.getElementsByTagName("p")[0].innerHTML.replace(/id\=\"[\w\W]*?\"/i,""));
                    }
                }
            }
            //console.log(task_id,api_id,btn_id,p_id);
            if(task_id.length>0&&api_id.length>0&&btn_id.length>0&&p_id.length>0){
                verify(0);
            }else if(task_id.length==0&&api_id.length==0&&btn_id.length==0&&p_id.length==0){
                var p2=document.createElement("p");
                p2.setAttribute("class", "card-text monospace");
                p2.setAttribute("style", "color:green");
                p2.innerHTML=`所有任务验证完成!`;
                div2.appendChild(p2);
                p2.scrollIntoView();
                getKey();
            }
        }
        function verify(e){
            var p=document.createElement("p");
            p.setAttribute("class", "card-text monospace");
            p.innerHTML=`验证任务${task_id[e]}:${p_id[e]}...`;
            div2.appendChild(p);
            p.scrollIntoView();
            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+="<font style='color:green'>OK!</font>";
                    }else{
                        document.getElementById(btn_id[e]).innerText="ERROR!";
                        document.getElementById(btn_id[e]).style.color="red";
                        document.getElementById(btn_id[e]).parentNode.getElementsByTagName("a")[0].click();
                        var msg=data.message||"ERROR";
                        p.innerHTML+=`<font style='color:red'>${msg}!</font>`;
                    }
                    e++;
                    if(e==btn_id.length-1){
                        document.getElementById(btn_id[e]).removeAttribute("disabled");
                        document.getElementById(btn_id[e]).click();
                    }
                    if(data.percentageNanoBar==100||e>=btn_id.length){
                        var p2=document.createElement("p");
                        p2.setAttribute("class", "card-text monospace");
                        p2.setAttribute("style", "color:green");
                        p2.innerHTML=`所有任务验证完成!`;
                        div2.appendChild(p2);
                        p2.scrollIntoView();
                        getKey();
                    }else{
                        verify(e);
                    }
                },
                error:function(jqXHR, textStatus, errorThrown){
                    document.getElementById(btn_id[e]).innerText="ERROR!";
                    document.getElementById(btn_id[e]).style.color="red";
                    document.getElementById(btn_id[e]).parentNode.getElementsByTagName("a")[0].click();
                    p.innerHTML+=`<font style='color:red'>${textStatus}:${jqXHR.status}-${errorThrown}</font>`;
                    e++;
                    if(e==btn_id.length-1){
                        document.getElementById(btn_id[e]).removeAttribute("disabled");
                        document.getElementById(btn_id[e]).click();
                    }
                    if(e<btn_id.length){
                        verify(e);
                    }else{
                        var p2=document.createElement("p");
                        p2.setAttribute("class", "card-text monospace");
                        p2.setAttribute("style", "color:green");
                        p2.innerHTML=`所有任务验证完成!`;
                        div2.appendChild(p2);
                        p2.scrollIntoView();
                        getKey();
                    }
                }
            });
        }
        function getKey(){
            if(/your[\s]*?key[\w\W]*?[\w\d]{5}(-[\w\d]{5}){2}/gim.test(document.getElementsByTagName("body")[0].innerText)){
                var p2=document.createElement("p");
                p2.setAttribute("class", "card-text monospace");
                p2.innerHTML=`你已经领取过key了!`;
                div2.appendChild(p2);
                p2.scrollIntoView();
                return 0;
            }
            if(/https?:\/\/gamezito.com\/giveaway\/[\w\W]*/.test(url)){
                var p1=document.createElement("p");
                p1.setAttribute("class", "card-text monospace");
                p1.innerHTML=`请手动完成谷歌验证获取key!`;
                //document.getElementById("get_key_container").style.display="block";
                div2.appendChild(p1);
                p1.scrollIntoView();
                google_verify();
            }else{
                var p=document.createElement("p");
                p.setAttribute("class", "card-text monospace");
                p.innerHTML=`获取key...`;
                div2.appendChild(p);
                p.scrollIntoView();
                $.ajax({
                    type: "post",
                    url: "/ajax/keys/get/key",
                    datatype: "json",
                    data:{
                        giveaway_slug: game,
                    },
                    crossDomain:true,
                    xhrFields: {
                        withCredentials: true
                    },
                    success: function (data) {
                        var key=data.key||"";
                        if(data.status==1&&/[\d\w]{5}(\-[\d\w]{5}){2}/.test(data.key)){
                            p.innerHTML+="<font style='color:green'>OK!</font>";
                            var p1=document.createElement("p");
                            p1.setAttribute("class", "card-text monospace");
                            p1.innerHTML=`YOUR KEY : <a href="https://store.steampowered.com/account/registerkey?key=${data.key}" target="_blank">${data.key}</a>`;
                            div2.appendChild(p1);
                            p1.scrollIntoView();
                            window.open("https://store.steampowered.com/account/registerkey?key="+data.key,"_blank");
                        }else{
                            var msg=data.message||"ERROR";
                            p.innerHTML+=`<font style='color:red'>${msg}!</font>`;
                        }
                    },
                    error:function(jqXHR, textStatus, errorThrown){
                        p.innerHTML+=`<font style='color:red'>${textStatus}:${jqXHR.status}-${errorThrown}</font>`;
                    }
                });
            }
        }
    }

    if(/https?:\/\/www.grabfreegame.com\/giveaway\/[\w\W]*/.test(url)){
        var verify_btn=[];
        var do_btn=[];
        document.getElementById("doTask").onclick=function(){
            verify_btn=[];
            do_btn=[];
            getBtn("d");
        };
        document.getElementById("Verify").onclick=function(){
            verify_btn=[];
            do_btn=[];
            getBtn("v");
        };
        div2.setAttribute("style", `position:fixed;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;`);
        function getBtn(e){
            var btn=document.getElementsByTagName("button");
            for(var i=0;i<btn.length;i++){
                if(/verify/i.test(btn[i].innerHTML)&&btn[i].id!="Verify"){
                    verify_btn.push(btn[i].onclick.toString().match(/\/\/www.grabfreegame.com\/giveaway\/[\w\W]*?\?verify\=[\d]+/)[0]);
                }
                if(/to[\w\W]*?do[\w\W]*/i.test(btn[i].innerHTML)&&btn[i].onclick){
                    do_btn.push(btn[i].onclick.toString().match(/\/\/www.grabfreegame.com\/giveaway\/[\w\W]*?\?q\=[\d]+/)[0]);
                }
            }
            if(do_btn.length>0&&e==="d"){
                doTask(0);
            }
            if(verify_btn.length>0&&e==="v"){
                verify_1(0);
            }
        }
        function doTask(e){
            var taskId=do_btn[e].match(/\?q\=[\d]+/)[0];
            taskId=taskId.replace("?q=","");
            var p=document.createElement("p");
            p.setAttribute("class", "code");
            p.innerHTML=`执行任务:${taskId}...`;
            div2.appendChild(p);
            p.scrollIntoView();
            $.ajax({
                type: "get",
                url: do_btn[e],
                datatype: "json",
                crossDomain:true,
                xhrFields: {
                    withCredentials: true
                },
                complete: function (data) {
                    p.innerHTML+="<font style='color:green'>OK!</font>";
                    e++;
                    if(e<do_btn.length){
                        doTask(e);
                    }else{
                        if(verify_btn.length>0){
                            verify_1(0);
                        }
                    }
                }
            });
        }
        function verify_1(e){
            var taskId=verify_btn[e].match(/\?verify\=[\d]+/)[0];
            taskId=taskId.replace("?verify=","");
            var p=document.createElement("p");
            p.setAttribute("class", "code");
            p.innerHTML=`验证任务:${taskId}...`;
            div2.appendChild(p);
            p.scrollIntoView();
            $.ajax({
                type: "get",
                url: verify_btn[e],
                datatype: "json",
                crossDomain:true,
                xhrFields: {
                    withCredentials: true
                },
                complete: function (data) {
                    p.innerHTML+="<font style='color:green'>OK!</font>";
                    e++;
                    if(e<verify_btn.length){
                        verify_1(e);
                    }else{
                        window.location.href=url;
                    }
                }
            });
        }
    }

    if(/https?:\/\/gamecode.win\/giveaway\/[\w\W]*/.test(url)){
        div2.setAttribute("class", "col-sm-8 text-center backgroundWhite finishAllTasksText matchColumn");
        btn_class("btn draw-border parallelogram");
        var g_task_url=[];
        var g_task_id=[];
        var g_task_ok=[];
        var g_btn=document.getElementsByTagName("button");
        for(var g=0;g<g_btn.length;g++){
            if((g_btn[g].innerText=="X"||/verify/i.test(g_btn[g].innerText))&&/listOfTasks_btnVerify/.test(g_btn[g].id)&&g_btn[g].style.display!="none"){
                var g_div=g_btn[g].parentNode.parentNode.parentNode;
                g_task_id.push(g_div.getElementsByTagName("input")[1].value);
                g_task_ok.push(g_div.getElementsByClassName("pull-right")[0]);
                var g_task=g_btn[g].id.replace(/listOfTasks_btnVerify_[\d]+_/i,"");
                switch(g_task){
                    case "others":
                        g_task_url.push("/ajax/social/others/clicked");
                        break;
                    case "t_followUser":
                        g_task_url.push("/ajax/social/twitter/followUser");
                        break;
                    case "s_joinGroup":
                        g_task_url.push("/ajax/social/steam/followGroup");
                        break;
                    case "w_followChannel":
                        g_task_url.push("/ajax/social/twitch/followCheck");
                        break;

                    default:

                        break;
                }
            }
        }
        //console.log(g_task_url,g_task_id);
        function g_do_task(e){
            var p=document.createElement("p");
            p.setAttribute("class", "code");
            p.innerHTML=`验证任务:${g_task_id[e]}...`;
            div2.appendChild(p);
            p.scrollIntoView();
            $.ajax({
                type: "post",
                url: g_task_url[e],
                datatype: "json",
                data:{
                    giveawayID: game,
                    taskID: g_task_id[e]
                },
                crossDomain:true,
                xhrFields: {
                    withCredentials: true
                },
                complete: function (data) {
                    var msg,task,zz;
                    var status=data.status==200?(data.responseJSON==undefined?0:(data.responseJSON.status==1?1:0)):0;
                    console.log(data);
                    if(status==1){
                        p.innerHTML+="<font style='color:green'>OK!</font>";
                        if(e==g_task_id.length-1){
                            g_task_ok[e].getElementsByTagName("button")[1].click();
                        }
                        g_task_ok[e].innerHTML=`<i class="fa fa-check checkMarkAfterCompleteTask"></i>`;
                    }else{
                        msg=data.message||"ERROR";
                        task=g_task_ok[e].getElementsByTagName("a")[0];
                        zz=document.createElement("div");
                        zz.appendChild(task);
                        task=zz.innerHTML;
                        p.innerHTML+=`<font style='color:red'>${msg}!</font>${task}`;
                    }
                    p.scrollIntoView();
                    e++;
                    if(e<g_task_id.length){
                        g_do_task(e);
                    }else{
                        var p1=document.createElement("p");
                        p1.setAttribute("class", "card-text monospace");
                        if(div2.getElementsByTagName("button").length>0){
                            p1.setAttribute("style", "color:red");
                            p1.innerHTML=`有任务未完成或验证失败,请手动完成任务之后在验证!`;
                        }else{
                            p1.setAttribute("style", "color:green");
                            p1.innerHTML=`所有任务验证完成,请手动完成谷歌验证获取key!`;
                        }
                        div2.appendChild(p1);
                        p1.scrollIntoView();
                    }
                }
            });

        }

        document.getElementById("doTask").onclick=function(){
            g_task_url=[];
            g_task_id=[];
            g_task_ok=[];
            if(g_task_id.length>0){
                g_do_task(0);
            }else{
                var p1=document.createElement("p");
                p1.setAttribute("style", "color:green");
                p1.innerHTML=`所有任务都已经完成了,快去领key吧!`;
                div2.appendChild(p1);
                p1.scrollIntoView();
            }
        };
        document.getElementById("Verify").onclick=function(){
            g_task_url=[];
            g_task_id=[];
            g_task_ok=[];
            if(g_task_id.length>0){
                g_do_task(0);
            }else{
                var p1=document.createElement("p");
                p1.setAttribute("style", "color:green");
                p1.innerHTML=`所有任务都已经完成了,快去领key吧!`;
                div2.appendChild(p1);
                p1.scrollIntoView();
            }
        };
    }
    function btn_class(e){
        var task_btn=document.getElementsByClassName("auto-task");
        for(var tb=0;tb<task_btn.length;tb++){
            task_btn[tb].setAttribute("class", e+" auto-task");
        }
    }
    if(/https?:\/\/whosgamingnow.net\/giveaway\/[\w\W]*/.test(url)){
        btn_class("btn btn-primary");
        function wsn_enter(){
            $.ajax({
                type: "post",
                url: url,
                datatype: "json",
                data:{
                    submit: "Enter",
                },
                crossDomain:true,
                xhrFields: {
                    withCredentials: true
                },
                success: function (data) {
                    if(/<h3>Steam key:<\/h3><p><strong class=\"SteamKey\">[\w\d]{5}(-[\w\W]{5}){2}<\/strong><\/p>/i.test(data)){
                        var key=data.match(/<h3>Steam key:<\/h3><p><strong class=\"SteamKey\">[\w\d]{5}(-[\w\W]{5}){2}<\/strong><\/p>/i)[0];
                        key=key.replace(/(<h3>Steam key:<\/h3><p><strong class="SteamKey">)|(<\/strong><\/p>)/gi,"");
                        data=data.replace(key,`<a href=https://store.steampowered.com/account/registerkey?key=${key} title="点击激活">${key}</a>`);
                    }
                    document.write(data);
                    //console.log(data);
                },
                error:function(jqXHR, textStatus, errorThrown){
                    alert(textStatus+":"+jqXHR.status+"-"+errorThrown);
                }
            });
        }
        document.getElementById("doTask").onclick=function(){
            wsn_enter();
        };
        document.getElementById("Verify").onclick=function(){
            wsn_enter();
        };
    }
    // Your code here...
})();