Лолз гивэвэй монитор

Следит за лимитом участий с отстуком в тг-бота

// ==UserScript==
// @name         Лолз гивэвэй монитор
// @version      1.0
// @description  Следит за лимитом участий с отстуком в тг-бота
// @author       MisterLis
// @match        https://lolz.live/forums/contests/*
// @grant        GM_xmlhttpRequest
// @namespace https://greasyfork.org/users/1508462
// ==/UserScript==

(function () {
    'use strict';

    const BOT_TOKEN = '';
    const CHAT_ID = '';
    const LEFT_MAX = 5;
    const RELOAD_MS = 60 * 1000;

    const sendTg = (text) => {
        GM_xmlhttpRequest({
            method: 'POST',
            url: `https://api.telegram.org/bot${BOT_TOKEN}/sendMessage`,
            headers: { 'Content-Type': 'application/json' },
            data: JSON.stringify({ chat_id: CHAT_ID, text })
        });
    };

    const checkLimit = () => {
        const node = document.querySelector('.counterText');
        if (!node) return;

        const [used, total] = node.textContent.trim().split('/').map(Number);
        const left = total - used;

        console.log(`Giveaway: ${used}/${total}, left=${left}`);

        if (left <= LEFT_MAX && !window.__tgSent) {
            sendTg(`⚠️ Осталось ${left} из ${total} попыток в розыгрышах lolz.live!\nНе забудьте создать розыгрыш https://lolz.live/forums/contests/create-thread`);
            window.__tgSent = true;
        }
    };

    checkLimit();
    setTimeout(() => location.reload(), RELOAD_MS);
})();