timer

q11e 代刷网站的定时提交控制脚本

As of 2025-05-05. See the latest version.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         timer
// @namespace    http://sugarblack.top
// @version      0.1.1
// @description  q11e 代刷网站的定时提交控制脚本
// @author       zemelee
// @license MIT
// @match        http://sugarblack.top/*
// ==/UserScript==

async function oneTime(count) {
    let homeBtn = document.querySelector("#home-btn");
    homeBtn.click()
    await new Promise((resolve) => { setTimeout(resolve, 1000); });
    let inputEl = document.querySelector('input[step="5"][max="100"]');
    inputEl.value = count
    const inputEvent = new Event('input', { bubbles: true });
    inputEl.dispatchEvent(inputEvent);
    await new Promise((resolve) => { setTimeout(resolve, 500); });
    let submitBtn = document.querySelector("#submit-btn");
    submitBtn.click()
    await new Promise((resolve) => { setTimeout(resolve, 1000); });
    const buttons = document.querySelectorAll('button');
    const confirmBtn = Array.from(buttons).filter(button => button.innerText.trim() === '确认');
    confirmBtn[0].click()
}

function showMessage(text, delay) {
    messageBox = document.createElement('div');
    messageBox.textContent = text;
    messageBox.style.cssText = `
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translateX(-50%);
        background-color: rgba(0, 0, 0, 0.8);
        color: white;
        padding: 10px 20px;
        border-radius: 5px;
        z-index: 9999;
    `;
    document.body.appendChild(messageBox);
    setTimeout(() => {
        document.body.removeChild(messageBox);
        messageBox = null; // 释放引用,准备下一次使用
    }, delay); // 4 seconds
}
function validate(inputs) {
    let inputNum = inputs[0]
    let inputInterval = inputs[1]
    let inputFor = inputs[2]
    if (!inputNum.value || !inputInterval.value || !inputFor.value) {
        showMessage("份数/间隔/循环次数 需要填写完整", 3500)
        return false
    }
    if (inputNum.value >= 88 || inputNum.value <= 1) {
        showMessage("提交次数区间为[2, 88]!", 3500)
        return false
    }
    if (inputInterval.value > 600 || inputInterval.value < 10) {
        showMessage("间隔时间区间为[10, 600s]!", 3500)
        return false
    }
    if (inputFor > 100 || inputFor < 1) {
        showMessage("循环次数区间为[1, 100]!", 3500)
        return false
    }
    return true
}

async function executeRepeatedly(delay, forTime, singleCnt) {
    let count = 0;
    async function execute() {
        if (count < forTime) {
            showMessage(`当前循环轮次:${count + 1}`, 5000)
            await oneTime(singleCnt); // 等待 oneTime() 完成
            count++;
            setTimeout(execute, delay * 1000);
        }
    }
    await execute();
    window.location.replace("http://sugarblack.top/#/home/params")
}


(async function () {
    'use strict';
    let singleCnt = localStorage.getItem("singleCnt") || null;
    let forTime = localStorage.getItem("forTime") || null;
    let delay = localStorage.getItem("delay") || null;
    await new Promise((resolve) => { setTimeout(resolve, 1000); });
    const btns = document.querySelector(".btns")
    btns.appendChild(document.createElement("br"))
    // 
    const label1 = document.createElement('label');
    const label2 = document.createElement('label');
    const label3 = document.createElement('label');
    label1.textContent = "份数";
    label2.textContent = "间隔";
    label3.textContent = "循环";
    let inputNum = document.createElement("input")
    let inputInterval = document.createElement("input")
    let inputFor = document.createElement("input")
    inputNum.placeholder = "每次提交的份数";
    inputInterval.placeholder = "提交间隔(秒)";
    inputFor.placeholder = "循环次数";
    // inputNum.className = "inputNum";
    // inputInterval.className = "inputInterval";
    // inputFor.className = "inputFor";
    if (singleCnt && forTime && delay) {
        inputNum.value = singleCnt;
        inputInterval.value = delay;
        inputFor.value = forTime;
    }
    let inputs = [inputNum, inputInterval, inputFor]
    let labels = [label1, label2, label3]
    inputs.forEach((item, index) => {
        item.style.marginLeft = "6px";
        item.style.marginRight = "20px";
        item.type = "number";
        item.style.width = "150px";
        btns.appendChild(labels[index]);
        btns.appendChild(item)
    })
    let startBtn = document.createElement("button")
    startBtn.textContent = "开始"
    startBtn.style.marginLeft = "10px";
    startBtn.addEventListener("click", function () {

        if (!validate(inputs)) return
        singleCnt = inputNum.value;
        forTime = inputFor.value;
        delay = inputInterval.value;
        localStorage.setItem("singleCnt", singleCnt)
        localStorage.setItem("forTime", forTime)
        localStorage.setItem("delay", delay)
        executeRepeatedly(delay, forTime, singleCnt)
    })
    btns.appendChild(startBtn)


})();