timer

for q11e

2025-07-23 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         timer
// @namespace    http://sugarblack.top
// @version      1.1.1
// @description  for q11e
// @author       zemelee
// @license      MIT
// @match        http://sugarblack.top/*
// ==/UserScript==
 
// 看!这!里!
//1.转到 TamperMonkey 插件,创建新脚本,删除新脚本里的所有内容
//2. 然后请将所有文本复制到脚本中并保存。刷新 http://sugarblack.top 就可以生效
//3. 如果未生效请打开浏览器的开发者模式。


async function oneTime(count) {
    let homeBtn = document.querySelector("#home-btn");
    homeBtn.click()
    await new Promise((resolve) => { setTimeout(resolve, 1000); });
    let inputEl = document.querySelector("#submit-number")
    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()
    let confirmBtn = document.querySelectorAll(".el-message-box>.el-message-box__btns>button")
    confirmBtn[0].click()


}
 
function showMessage(text, delay) {
    let 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 minInterval = inputs[1]
    let maxInterval = inputs[2]
    let inputFor = inputs[3]

    if (!inputNum.value || !minInterval.value || !maxInterval.value || !inputFor.value) {
        showMessage("minInterval maxInterval inputNum cycles need to be filled in completely", 3500)
        return false
    }
    if (Number(inputNum.value) >= 10 || Number(inputNum.value) < 1) {
        showMessage("输入数量必须大于1、小于10", 3500)
        return false
    }
    if (Number(minInterval.value) >= Number(maxInterval.value)) {
        showMessage("最小间隔必须小于最大间隔时长!", 3500)
        return false
    }
    if (Number(minInterval.value) < 10) {
        showMessage("最小间隔必须大于10s!", 3500)
        return false
    } 

    if (Number(inputFor.value) > 150 || Number(inputFor.value) < 1) {
        showMessage("循环次数介于[1, 150]之间!", 3500)
        return false
    }
    return true
}
 
async function executeRepeatedly(minDelay, maxDelay, forTime, singleCnt) {
    let count = 0;
    async function execute() {
        if (count < forTime) {
            const delay = Math.floor(Math.random() * (maxDelay - minDelay + 1)) + minDelay;
            showMessage(`Current cycle: ${count + 1}, Delay: ${delay}s`, 5000);
            await oneTime(singleCnt);
            count++;
            setTimeout(execute, delay * 1000);
        }
    }

    await execute();
    window.location.replace("http://sugarblack.top/#/home/params");
}


 
(async function () {
    'use strict';
    
    let singleCnt = localStorage.getItem("singleCnt") || 1;
    let minInterval = localStorage.getItem("minInterval") || 10;
    let maxInterval = localStorage.getItem("maxInterval") || 30;
    let forTime = localStorage.getItem("forTime") || 5;
    await new Promise((resolve) => { setTimeout(resolve, 1000); });
    const btns = document.querySelector(".btns")
    console.log(111, btns)
    btns.appendChild(document.createElement("br"))

    const label1 = document.createElement('label');
    const label2 = document.createElement('label');
    const label3 = document.createElement('label');
    const label4 = document.createElement('label');

    label1.textContent = "每次提交数量(建议1)";
    label2.textContent = "最小间隔(s)";
    label3.textContent = "最大间隔(s)";
    label4.textContent = "循环次数";

    let inputNum = document.createElement("input")
    let inputMinInterval = document.createElement("input")
    let inputMaxInterval = document.createElement("input")
    let inputFor = document.createElement("input")

    inputNum.placeholder = "inputNum";
    inputMinInterval.placeholder = "Min Interval (s)";
    inputMaxInterval.placeholder = "Max Interval (s)";
    inputFor.placeholder = "Number of cycles";

    if (singleCnt && minInterval && maxInterval && forTime) {
        inputNum.value = singleCnt;
        inputMinInterval.value = minInterval;
        inputMaxInterval.value = maxInterval;
        inputFor.value = forTime;
    }

    let inputs = [inputNum, inputMinInterval, inputMaxInterval, inputFor];
    let labels = [label1, label2, label3, label4];

    inputs.forEach((item, index) => {
        item.style.marginLeft = "6px";
        item.style.marginRight = "20px";
        item.style.width = "50px";
        item.type = "number";
        btns.appendChild(labels[index]);
        btns.appendChild(item);
    })

    let startBtn = document.createElement("button")
    startBtn.textContent = "start"
    startBtn.style.marginLeft = "10px";
    startBtn.addEventListener("click", function () {

        if (!validate(inputs)) return

        singleCnt = inputNum.value;
        const newMinInterval = inputMinInterval.value;
        const newMaxInterval = inputMaxInterval.value;
        forTime = inputFor.value;

        localStorage.setItem("singleCnt", singleCnt)
        localStorage.setItem("minInterval", newMinInterval)
        localStorage.setItem("maxInterval", newMaxInterval)
        localStorage.setItem("forTime", forTime)

        executeRepeatedly(+newMinInterval, +newMaxInterval, +forTime, +singleCnt)
    })
    btns.appendChild(startBtn)
 
 
})();