RateLimit Bypass

Send custom requests when emote buttons are clicked

当前为 2024-04-29 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         RateLimit Bypass
// @namespace    RishiSunak
// @version      0.1
// @description  Send custom requests when emote buttons are clicked
// @author       You
// @match        https://kick.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';


    const authToken = 'Bearer YOUR_AUTH_TOKEN_HERE'; // Replace 'YOUR_AUTH_TOKEN_HERE' with your actual token
    const xsrfToken = 'YOUR_XSRF_TOKEN_HERE'; // Replace 'YOUR_XSRF_TOKEN_HERE' with your actual XSRF token

    function sendRequest(chatId, emoteNumber, xsrfToken) {
        const headers = {
            'Accept': 'application/json, text/plain, */*',
            'Authorization': authToken,
            'X-Xsrf-Token': xsrfToken,
            'Origin': 'https://kick.com',
            'Referer': 'https://kick.com/nickwhite',
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36',
            'Content-Type': 'application/json'
        };

        const url = 'https://kick.com/api/v2/messages/send/' + chatId;
        const jsonData = JSON.stringify({
            'content': `[emote:${emoteNumber}:RishiBypass]`,
            'type': 'message'
        });

        fetch(url, {
            method: 'POST',
            headers: headers,
            credentials: 'include',
            body: jsonData
        }).then(response => {
            if (!response.ok) {
                throw new Error('Failed to send request');
            }
            console.log('Request sent successfully');
        }).catch(error => {
            console.error('Error sending request:', error);
        });
    }

    function attachEventListeners(chatId) {
        const emoteItems = document.querySelectorAll('img[src*="/emotes/"]');
        emoteItems.forEach(emote => {
            const clone = emote.cloneNode(true);
            emote.parentNode.replaceChild(clone, emote);
        });

        const newEmoteItems = document.querySelectorAll('img[src*="/emotes/"]');
        newEmoteItems.forEach(emote => {
            emote.addEventListener('click', function(event) {
                event.preventDefault();
                event.stopPropagation();
                console.log('Clicked IMG element:', event.target);
                console.log('SRC:', event.target.src);
                const emoteNumber = event.target.src.match(/\/emotes\/(\d+)\/fullsize/)[1];
                console.log('Emote Number:', emoteNumber);
                sendRequest(chatId, emoteNumber, xsrfToken);
                attachEventListeners(chatId);
            });
        });
    }

    setTimeout(function() {
        fetch('https://kick.com/api/v2/channels/' + window.location.pathname.split('/').pop(), {
            method: 'GET',
            credentials: 'include'
        }).then(response => {
            if (!response.ok) {
                throw new Error('Failed to fetch chat ID');
            }
            return response.json();
        }).then(data => {
            const chatId = data.chatroom && data.chatroom.id ? data.chatroom.id : null;
            if (!chatId) {
                throw new Error('Chat ID not found in response');
            }
            console.log('Chat ID:', chatId);

            attachEventListeners(chatId);
        }).catch(error => {
            console.error('Error:', error);
        });
    }, 3000); 


function hideRateLimitMessage() {
    const toastHolder = document.querySelector('.toast-holder');
    if (toastHolder) {
        toastHolder.style.display = 'none';
    }
}

function attachHideRateLimitListeners() {
    const observerTarget = document.querySelector('body');
    const observer = new MutationObserver(mutationsList => {
        mutationsList.forEach(mutation => {
            if (mutation.addedNodes.length > 0) {
                mutation.addedNodes.forEach(addedNode => {
                    if (addedNode.nodeType === 1) {
                        if (addedNode.classList && addedNode.classList.contains('toast-holder')) {
                            hideRateLimitMessage();
                        }
                    }
                });
            }
        });
    });

    const observerConfig = { childList: true, subtree: true };
    observer.observe(observerTarget, observerConfig);
}


hideRateLimitMessage();
attachHideRateLimitListeners();
})();