astars club Mega Clicker

fuck him all )

当前为 2025-02-27 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         astars club Mega Clicker
// @namespace    animestars.org
// @description  fuck him all )
// @author       astars lover
// @version      0.17
// @match        https://astars.club/clubs/*/boost/
// @match        https://asstars1.astars.club/clubs/*/boost/
// @match        https://animestars.org/clubs/*/boost/
// @match        https://as1.astars.club/clubs/*/boost/
// @match        https://asstars.tv/clubs/*/boost/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=astars.club
// @grant        none
// @license MIT
// ==/UserScript==

// Сохраняем оригинальные методы
const originalPush = { ...DLEPush };

let lastText = '';

let newAlert = function(text) {
    if (lastText != text) {
        console.log(text);
        lastText = text;
    }
}

// Отключаем уведомления
DLEPush.info = newAlert;
DLEPush.success = newAlert;
DLEPush.warning = newAlert;
DLEPush.error = newAlert;

const userHash = dle_login_hash ?? '';
const REQUEST_DELAY = 8;
let requestCount = 0;
let totalBoosted = 0;
const AUTO_START_TIME = "21:01"; // Время автозапуска в формате HH:MM (по Москве)
let countdownInterval;
let refreshInterval;
let startBtnId = 'startBtnId';

function createButton() {
    const button = document.createElement("button");
    button.id = startBtnId;
    button.innerText = "Ожидание...";
    button.style.position = "fixed";
    button.style.right = "10px";
    button.style.top = "50%";
    button.style.transform = "translateY(-50%)";
    button.style.padding = "10px 20px";
    button.style.fontSize = "16px";
    button.style.backgroundColor = "red";
    button.style.color = "white";
    button.style.border = "none";
    button.style.cursor = "pointer";
    button.style.zIndex = "1000";
    document.body.appendChild(button);

    updateButtonCountdown(button);
    countdownInterval = setInterval(() => updateButtonCountdown(button), 1000);

    button.addEventListener("click", processBoosting);
    createInfoBlock();
}

function updateButtonCountdown(button) {
    const now = new Date();
    const moscowTime = new Date(now.toLocaleString("en-US", { timeZone: "Europe/Moscow" }));
    const [targetHour, targetMinute] = AUTO_START_TIME.split(":").map(Number);
    const targetTime = new Date(moscowTime);
    targetTime.setHours(targetHour, targetMinute, 0, 0);
    if (targetTime < moscowTime) targetTime.setDate(targetTime.getDate() + 1);

    const diff = targetTime - moscowTime;
    if (diff <= 0) {
        button.innerText = "Жми сюда и запускай!";
        clearInterval(countdownInterval);
    } else {
        const hours = String(Math.floor(diff / (1000 * 60 * 60))).padStart(2, '0');
        const minutes = String(Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60))).padStart(2, '0');
        const seconds = String(Math.floor((diff % (1000 * 60)) / 1000)).padStart(2, '0');
        button.innerText = `${hours}:${minutes}:${seconds}`;
    }
}

function createInfoBlock() {
    const infoBlock = document.createElement("div");
    infoBlock.id = "boost-info";
    infoBlock.style.position = "fixed";
    infoBlock.style.right = "10px";
    infoBlock.style.top = "60%";
    infoBlock.style.transform = "translateY(-50%)";
    infoBlock.style.padding = "10px";
    infoBlock.style.fontSize = "14px";
    infoBlock.style.backgroundColor = "black";
    infoBlock.style.color = "white";
    infoBlock.style.border = "1px solid white";
    infoBlock.style.zIndex = "1000";
    infoBlock.innerHTML = `Количество запросов: 0<br>Сдано карточек: 0`;
    document.body.appendChild(infoBlock);
}

function updateInfoBlock() {
    const infoBlock = document.getElementById("boost-info");
    if (infoBlock) {
        infoBlock.innerHTML = `Количество запросов: ${requestCount}<br>Сдано карточек: ${totalBoosted}`;
    }
}

async function sendBoostRequest(cardId, clubId) {
    await new Promise(resolve => setTimeout(resolve, REQUEST_DELAY));
    requestCount++;
    updateInfoBlock();
    const url = "/clubs/" + clubId + "/boost/";
    const data = { action: "boost", card_id: cardId, user_hash: userHash };

    try {
        const response = await fetch(url, {
            method: "POST",
            headers: { "Content-Type": "application/x-www-form-urlencoded" },
            body: new URLSearchParams(data)
        });
        return await response.json();
    } catch (error) {
        // DLEPush?.info(error);
        return null;
    }
}

async function sendRefreshRequest(cardId) {
    await new Promise(resolve => setTimeout(resolve, REQUEST_DELAY));
    requestCount++;
    updateInfoBlock();
    const url = "/engine/ajax/controller.php?mod=clubs_ajax";
    const data = { action: "boost_refresh", card_id: cardId, user_hash: userHash };

    try {
        const response = await fetch(url, {
            method: "POST",
            headers: { "Content-Type": "application/x-www-form-urlencoded" },
            body: new URLSearchParams(data)
        });
        return await response.json();
    } catch (error) {
        // DLEPush?.info(error);
        return null;
    }
}

function parseBoostHtml(html) {
    const parser = new DOMParser();
    const doc = parser.parseFromString(html, "text/html");
    const boostBtn = doc.querySelector(".club__boost-btn");
    const refreshBtn = doc.querySelector(".club__boost__refresh-btn");
    return { boostBtn, refreshBtn };
}

function autoClickRefreshButton() {
    refreshInterval = setInterval(() => {
        const refreshButton = document.querySelector(".club__boost__refresh-btn");
        if (refreshButton) {
            refreshButton.click();
            console.log("Кнопка обновления буста нажата");
        }
    }, 5000);
}

async function processBoosting() {
    DLEPush?.success('Вперед, отаки! Начинаем эпичный марафон!');
    autoClickRefreshButton();
    document.getElementById(startBtnId)?.remove();
    let btn = document.querySelector(".club__boost-btn") || document.querySelector(".club__boost__refresh-btn");
    let cardId = 0;
    let clubId = 0;
    let response = {};
    while (true) {
        let response = {};
        if (btn) {
            cardId = btn.getAttribute("data-card-id");
            clubId = btn.getAttribute("data-club-id");
            response = await sendBoostRequest(cardId, clubId);

            if (response?.error) {
                console.log(response.error);
                if (response.error.includes("Достигнут дневной лимит. все.")) {
                    finishBoost("Достигнут дневной лимит. все.")
                    break;
                }
            }

            if (response?.boost_count) {
                totalBoosted = response.boost_count;
                updateInfoBlock();
            }

            if (response?.boost_html_changed) {
                let { boostBtn: newBoostBtn, refreshBtn: newRefreshBtn } = parseBoostHtml(response.boost_html_changed);
                btn = newBoostBtn || newRefreshBtn;
            }
        } else {
            finishBoost('Кнопки не найдены. все.');
            break;
        }

        if (response?.error) {
            cardId = btn.getAttribute("data-card-id");
            response = await sendRefreshRequest(cardId);

            if (response?.boost_count === "300") {
                finishBoost("Достигнут лимит бустов. все.");
                break;
            }

            if (response?.boost_count) {
                totalBoosted = response.boost_count;
                updateInfoBlock();
            }

            if (response?.boost_html) {
                let { boostBtn: newBoostBtn, refreshBtn: newRefreshBtn } = parseBoostHtml(response.boost_html);
                btn = newBoostBtn || newRefreshBtn;
            }

            if (response?.error) {
                // DLEPush?.info(response.error);
                console.log(response.error);
            }
        }
    }
}

function finishBoost(text) {
    clearInterval(refreshInterval);
    Object?.assign(DLEPush, originalPush);
    DLEPush?.info(text);
}


(function() {
    'use strict';
    if (/^\/clubs\/\d+\/boost\/$/.test(window.location.pathname)) {
        createButton();
    }
})();