Greasy Fork

来自缓存

Greasy Fork is available in English.

自动任务

try to take over the world!

当前为 2018-07-30 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         自动任务
// @namespace    http://tampermonkey.net/
// @version      0.3
// @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/*
// @grant        GM_xmlhttpRequest
// ==/UserScript==

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


    if(/https?:\/\/(marvelousga|dupedornot|gamezito).com\/giveaway\/[\w\W]*/.test(url)){
        document.getElementById("doTask").onclick=function(){
            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)){
                        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");
            }
            */
                }
            }
        };
        document.getElementById("Verify").onclick=function(){
            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 webpage(taskId,e,text){
            var p=document.createElement("p");
            p.setAttribute("class", "card-text monospace");
            p.innerHTML=`开始任务${taskId}:${text}...`;
            div2.appendChild(p);
            //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();
                    }
                }
            });
        }
        /*
    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)&&btn[i].disabled===false){
                    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("p")[0].innerHTML.replace(/id\=\"[\w\W]*?\"/i,""));
                    }else{
                        p_id.push(btn[i].parentNode.getElementsByTagName("p")[0].innerHTML.replace(/id\=\"[\w\W]*?\"/i,""));
                    }
                }
            }
            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);
                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);
            $.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){
                        verify(e);
                    }else{
                        var p2=document.createElement("p");
                        p2.setAttribute("class", "card-text monospace");
                        p2.setAttribute("style", "color:green");
                        p2.innerHTML=`所有任务验证完成!`;
                        div2.appendChild(p2);
                        getKey();
                    }
                }
            });
        }
        function getKey(){
            var p=document.createElement("p");
            p.setAttribute("class", "card-text monospace");
            p.innerHTML=`获取key...`;
            div2.appendChild(p);
            $.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);
                        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>`;
                    }
                }
            });
        }
    }

    if(/https?:\/\/www.grabfreegame.com\/giveaway\/[\w\W]*/.test(url)){
        var verify_btn=[];
        var do_btn=[]
        document.getElementById("doTask").onclick=function(){
            getBtn("d");
        };
        document.getElementById("Verify").onclick=function(){
            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){
            $.ajax({
                type: "get",
                url: do_btn[e],
                datatype: "json",
                crossDomain:true,
                xhrFields: {
                    withCredentials: true
                },
                complete: function (data) {
                    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);
                    e++;
                    if(e<do_btn.length){
                        doTask(e);
                    }else{
                        if(verify_btn.length>0){
                            verify_1(0);
                        }
                    }
                }
            });
        }
        function verify_1(e){
            $.ajax({
                type: "get",
                url: verify_btn[e],
                datatype: "json",
                crossDomain:true,
                xhrFields: {
                    withCredentials: true
                },
                complete: function (data) {
                    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);
                    e++;
                    if(e<verify_btn.length){
                        verify_1(e);
                    }else{
                        window.location.href=url;
                    }
                }
            });
        }
    }
    // Your code here...
})();