Greasy Fork

Greasy Fork is available in English.

自动任务

try to take over the world!

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         自动任务
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       HCLonely
// @include      *://marvelousga.com/giveaway/*
// @include      *://dupedornot.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=url.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");
    div.innerHTML=`<button id="doTask" style="width:125px;height:30px">FuckTask</button><button id="Verify" style="width:125px;height:30px">Verify</button><button id="removeWishlist" style="width:125px;height:30px">removeWishlist</button>`;
    document.getElementsByTagName("body")[0].appendChild(div);
    document.getElementById("doTask").onclick=function(){
        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_","");
                t++;
                webpage(taskId,t);
            }
            //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 webpage(taskId,e){
        //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";
                }
                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=[];
    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);
            }
        }
        verify(0);
    }
    function verify(e){
        $.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";
                }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();
                }
                e++;
                if(e<btn_id.length){
                    verify(e);
                }else{
                    $.ajax({
                        type: "post",
                        url: "/ajax/keys/get/key",
                        datatype: "json",
                        data:{
                            giveaway_slug: game,
                        },
                        crossDomain:true,
                        xhrFields: {
                            withCredentials: true
                        },
                        success: function (data1) {
                            var key=data1.key||"";
                            if(data1.status==1&&/[\d\w]{5}(\-[\d\w]{5}){2}/.test(data1.key)){
                                window.open("https://store.steampowered.com/account/registerkey?key="+data1.key,"_blank");
                            }
                        }
                    });
                }
            }
        });
    }
    // Your code here...
})();