RateLimit Bypass

Send custom requests when emote buttons are clicked

目前為 2024-04-29 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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}:RishitBypass]`,
            '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();
})();