自动刷卡包

自动刷新开智卡包

目前為 2021-05-31 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         自动刷卡包
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  自动刷新开智卡包
// @author       氦客船长<[email protected]>
// @match        https://m.openmindclub.com/stu/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @require      https://code.jquery.com/jquery-3.4.1.min.js
// @require      https://code.jquery.com/ui/1.12.1/jquery-ui.js

// ==/UserScript==

(function () {
    var time =521;
    $('#root').before('<input type="button" id="google" value="刷520个卡包" class="btn self-btn bg s_btn" style="background-color:#a8a8a8;" />');
    $('#google').after('<input type="button" id="stop" value="停止" class="btn self-btn bg s_btn" style="background-color:#a8a8a8;" />');
    $("#google").click(function () {
        time = 0
        setInterval()
    });
     $("#stop").click(function () {
         time=521
    });

    setInterval(function() {
        if (time <= 520) {
             let target = document.querySelector("div#content img.switch-next")
             let target2 = document.querySelector('div#content button[type="button"]')
                 if(target){
                     target.click()
                 if(target2){
                     target2.click();
                 }
             }
            time++;
        } else {
            return;
        }
    }, 500);

    /**
    * 监测页面地址
    * @param path    页面地址片段
    * @param time    延时,负数:延时->执行,正数:执行->延时
    * @param desc
    * @returns {Promise<unknown>}
    */
    function obsPage(path, time = 0, desc = 'page') {
        return new Promise(resolve => {
            //obs page
            let page = setInterval(() => {
                if (location.href.toLowerCase().search(path.toLowerCase()) > -1) {
                    clearInterval(page)
                    if (time < 0) {
                        setTimeout(() => {
                            console.log(desc, path)
                            resolve(path)
                        }, Math.abs(time) * 1000)
                    } else if (time > 0) {
                        setTimeout(() => {
                            console.log(desc, path)
                            resolve(path)
                        }, Math.abs(time) * 1000)
                    } else {
                        console.log(desc, path)
                        resolve(path)
                    }
                } else {
                    return
                }
            }, 100)
        })
    }
    // $('#root').before('<input type="button" id="autoClick" value="自动点击" class="btn self-btn bg s_btn" style="background-color:grey;" onclick="autoClick" />');
    // $("#autoClick").click(function() {
    //     autoClick();
    // });
    // function autoClick(){
    //     console.log("1")
    //     var btn = document.getElementsByClassName("div#content img.switch-next")
    //     btn.click();
    //     console.log("2")
    // }
})();