黑糖

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

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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         黑糖
// @namespace    http://sugarblack.top
// @version      0.1.0
// @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)


})();