astars club Mega Clicker

fuck him all )

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

// ==UserScript==
// @name         astars club Mega Clicker
// @namespace    animestars.org
// @description  fuck him all )
// @author       astars lover
// @version      0.1
// @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 userHash = dle_login_hash;
const REQUEST_DELAY = 10;
let requestCount = 0;
let totalBoosted = 0;

function createButton() {
    const button = document.createElement("button");
    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";
    button.addEventListener("click", processBoosting);
    document.body.appendChild(button);

    createInfoBlock();
}

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) {
    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) {
        return null;
    }
}

async function sendRefreshRequest(cardId) {
    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) {
        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 };
}

async function processBoosting() {
    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) {
                DLEPush?.info(response.error);
                console.log(response.error);
                if (response.error.includes("Достигнут дневной лимит. все.")) {
                    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 {
            DLEPush?.info('Кнопки не найдены. все.');
            break;
        }

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

            if (response?.boost_count === "300") {
                DLEPush?.info("Достигнут лимит бустов. все.");
                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) {
                console.log(response.error);
            }
        }

        await new Promise(resolve => setTimeout(resolve, REQUEST_DELAY));
    }
}

(function() {
    'use strict';

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