keyjoker半自动任务(伪)

keyjoker半自动任务,修改自https://gf.qytechs.cn/zh-CN/scripts/383411,部分操作需手动辅助

目前为 2020-07-06 提交的版本。查看 最新版本

// ==UserScript==
// @name         keyjoker半自动任务(伪)
// @namespace    https://gf.qytechs.cn/zh-CN/scripts/406476
// @version      0.3.2
// @description  keyjoker半自动任务,修改自https://gf.qytechs.cn/zh-CN/scripts/383411,部分操作需手动辅助
// @author       祭夜
// @include      *://www.keyjoker.com/entries*
// @include      *://dashboard.hcaptcha.com/*
// @include      *://steamcommunity.com/profiles/*?type=keyjoker
// @include      *://steamcommunity.com/groups/*
// @include      *?type=keyjoker
// @supportURL   https://www.jysafe.cn/
// @homepage     https://www.jysafe.cn/
// @run-at       document-end
// @grant        GM_registerMenuCommand
// @grant        GM_addStyle
// @grant        GM_xmlhttpRequest
// @grant        GM_setClipboard
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_openInTab
// @grant        GM_log
// @require      https://cdn.staticfile.org/jquery/3.3.1/jquery.min.js
// ==/UserScript==

(function() {
    'use strict';

    function reLoad(time,sum){
        let date=new Date();
        let hour=date.getHours();
        let min=date.getMinutes()<10?("0"+date.getMinutes()):date.getMinutes();
        if(GM_getValue("start")==1){
            $(".border-bottom").text(hour+":"+min+" 执行新任务检测");
            $.ajax({
                url:"/entries/load",
                type:"get",
                headers:{'x-csrf-token': $('meta[name="csrf-token"]').attr('content')},
                success:(data)=>{
                    if(data && (data.actions && (data.actions.length > sum) )){
                        console.log(data);
                        let date=new Date();
                        let hour=date.getHours();
                        let min=date.getMinutes()<10?("0"+date.getMinutes()):date.getMinutes();
                        $(".border-bottom").text(hour+":"+min+" 检测到新任务");
                        $show({
                            title:"keyjoker新任务",
                            msg:"keyjoker网站更新"+(data.actions.length-sum)+"个新任务!",
                            icon:"https://www.keyjoker.com/favicon-32x32.png",
                            time:0,
                            onclick:function(){
                                location.reload(true);
                            }
                        });
                        // 新窗口打开任务链接(免跳转)
                        for(var i = 0; i < data.actions.length; i++)
                        {
                            console.log(data.actions[i]);
                            window.open(data.actions[i].data.url + "?type=keyjoker");
                        }
                        // 重载任务列表
                        document.getElementsByClassName("row")[1].parentNode.removeChild(document.getElementsByClassName("row")[1]);
                        $('.layout-container').append('<entries-component></entries-component>');
                        $.getScript("/js/app.js");
                        // 检查任务是否完成
                        let checkComplete=setInterval(()=>{
                            if(document.getElementsByClassName("card mb-4 list-complete-item").length == 0){
                                // 停止检查操作
                                clearInterval(checkComplete);
                                // 重新开始检查任务
                                setTimeout(()=>{
                                    reLoad(time,0);
                                },time);
                            }
                        },2000);
                    }else{
                        setTimeout(()=>{
                            reLoad(time,sum);
                        },time);
                    }
                },
                error:(err)=>{
                    window.location.reload(true);
                }
            });
        }
    }
    function setTime(){
        let time=prompt('请输入获取任务信息的时间间隔(单位:秒):');
        if(!isNaN(time)){
            GM_setValue("time",parseInt(time));
        }
    }
    function start(){
        $showTest();
        GM_setValue("start",1);
        let time=GM_getValue("time");
        if(!time){
            time=60;
        }
        if(confirm("是否以时间间隔"+time+"秒进行任务检测?")){
            next();
        }
    }
    function next(){
        let time=GM_getValue("time");
        if(!time){
            time=60;
        }
        let sum=$(".list-complete-item").length;
        if(sum>0){
            reLoad(time*1000,sum);
        }else{
            reLoad(time*1000,0);
        }
    }
    function appHandle(){
        switch(location.hostname)
        {
            case "dashboard.hcaptcha.com":
                // hcaptcha 登录(不可用)、设置Cookie
                {
                    let hcaptchaClick=setInterval(()=>{
                        console.log("hCaptcha");
                        if(document.getElementsByTagName('button').length == 1)
                        {
                            if(document.getElementsByTagName('button')[0].innerText == "Login")
                            {
                                console.log("Login");
                                document.getElementsByTagName('button')[0].click();
                            }else if(document.getElementsByTagName('button')[0].innerText == "Set Cookie"){
                                console.log("Set Cookie");
                                document.getElementsByTagName('button')[0].click();
                                clearInterval(hcaptchaClick);
                            }
                        }
                    },1000);
                }
                break;
            case "store.steampowered.com":
                // Steam 添加愿望单
                if(document.referrer == "https://www.keyjoker.com/")
                {
                    document.getElementById("add_to_wishlist_area").lastElementChild.click();
                }
                break;
            case "www.twitch.tv":
                // twitch关注
                if(document.referrer == "https://www.keyjoker.com/")
                {
                    let twitchClick=setInterval(()=>{
                        if(document.getElementsByClassName("follow-btn__follow-btn").length == 1)
                        {
                            document.getElementsByClassName("follow-btn__follow-btn")[0].getElementsByTagName("button")[0].click();
                            clearInterval(twitchClick);
                        }
                    }, 1000);
                }
                break;
            case "steamcommunity.com":
                // Steam
                if(document.referrer == "https://www.keyjoker.com/")
                {
                    // 来源keyjoker
                    switch(location.pathname.split("/")[1])
                    {
                        case "groups":
                            // 加组
                            {
                                let steamClick=setInterval(()=>{
                                    if(document.getElementsByClassName("grouppage_join_area").length == 1)
                                    {
                                        document.getElementsByClassName("grouppage_join_area")[0].getElementsByTagName("a")[0].click();
                                        clearInterval(steamClick);
                                    }
                                }, 1000);
                            }
                            break;
                        case "profiles":
                            // 评论
                            {
                                let profileClick=setInterval(()=>{
                                    if(document.getElementsByClassName("commentthread_entry_quotebox").length == 1 && document.getElementsByClassName("commentthread_comments")[0].innerText.indexOf(document.getElementById("account_pulldown").innerText) != -1)
                                    {
                                        document.getElementsByClassName("commentthread_entry_quotebox")[0].firstElementChild.value="+rep";
                                        document.getElementsByClassName("commentthread_entry_submitlink")[0].getElementsByClassName("btn_green_white_innerfade btn_small")[0].click();
                                        clearInterval(profileClick);
                                    }
                                }, 1000);
                            }
                            break;
                        default :
                            break;
                    }
                }
                break;
            case "twitter.com":
                if(document.referrer == "https://www.keyjoker.com/")
                {
                    let twitterClick=setInterval(()=>{
                        if(document.getElementsByTagName("article").length > 0)
                        {
                            jQuery('div[data-testid="retweet"]').click();
                            jQuery('div[data-testid="retweetConfirm"]').click();
                            clearInterval(twitterClick);
                        }
                    },1000);
                    break;
                }
                break;
            default :
                break;
        }
    }
    if(document.getElementsByClassName("cf-section cf-highlight cf-captcha-container").length != 0)
    {
        console.log("cf验证页面!");
    }else if(document.getElementById("logout-form") && location.search !== "")
    {
        location.href = location.pathname;
    }else if(location.href == "https://www.keyjoker.com/entries")
    {
        console.log("keyjoker页面!");
        let isStart=setInterval(()=>{
            if(GM_getValue("start")==1){
                clearInterval(isStart);
                next();
            }
        },1000);
    }else{
        appHandle();
    }
    GM_registerMenuCommand("设置时间间隔",setTime);
    GM_registerMenuCommand("开始检测",start);
    GM_registerMenuCommand("停止检测",()=>{
        let date=new Date();
        let hour=date.getHours();
        let min=date.getMinutes()<10?("0"+date.getMinutes()):date.getMinutes();
        GM_setValue("start",0);
        $(".border-bottom").text(hour+":"+min+" 停止执行新任务检测");
    });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址