Auto Stickers for NT

Forget to show your stickers in a race? This script will help you!

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Auto Stickers for NT
// @namespace    https://singdev.wixsite.com/sing-developments/nitro
// @version      2.0
// @description  Forget to show your stickers in a race? This script will help you!
// @author       Sing Developments
// @match        https://nitrotype.com/race
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Define the frequency of hitting the shift key (in milliseconds) and posting stickers
    var shift_key_interval = 10000;   // Interval to hit the shift key (in milliseconds)
    var frequency_of_stickers = 50;    // Adjust this value for different frequencies

    // Function to check if the page is fully loaded
    function isPageFullyLoaded() {
        return document.readyState === 'complete';
    }

    // Function to click the chat picker button and post stickers
    function click_the_b(a) {
        // Hit the shift key periodically
        setInterval(function() {
            simulateKeyEvent('keydown', 16);  // 16 is the keycode for the shift key
            simulateKeyEvent('keyup', 16);
        }, shift_key_interval);

        // Check if a sticker should be posted based on frequency
        if (Math.random() * 100 <= frequency_of_stickers) {
            var total_choices = a.length;
            var current_choice = Math.floor(Math.random() * total_choices);
            a[current_choice].click();
        }
    }

    // Function to simulate keyboard events
    function simulateKeyEvent(type, keyCode) {
        var event = new KeyboardEvent(type, {
            bubbles: true,
            keyCode: keyCode,
            which: keyCode // Specify the 'which' property for better compatibility
        });
        document.dispatchEvent(event);
    }

    // Wait for the page to fully load before performing any actions
    var checkPageInterval = setInterval(function() {
        if (isPageFullyLoaded()) {
            clearInterval(checkPageInterval);

            // Check for the presence of the chat picker button
            var a = document.getElementsByClassName('raceChat-pickerOpt');
            if (a.length > 0) {
                click_the_b(a);
            }
        }
    }, 100); // Check every 100ms if the page is fully loaded
})();