Gats.io - Chat scroller (working!)

chat scroller for gats.io

当前为 2022-04-08 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Gats.io - Chat scroller (working!)
// @namespace    http://tampermonkey.net/
// @version      3.0
// @description  chat scroller for gats.io
// @author       nitrogem35
// @match        https://gats.io
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

//lmao how fcking stupid is this dev?? he didn't bother fixing chat scrollers properly twice now ahahahah add a rate limit you dumbass
var chatLoop;
//var symbols = ['@', '#', '!', '$', '%', '&'];
//var extraSymbols = [' '];
var maxLength;
var scrollText = ''
var scrollSpeed = 200
function startChatLoop() {
    chatLoop = true
    let s = scrollText
    let i = 0
    let e = 0
    let k = 0
    function loopfunc() {
        i % 12 == 0 ? e = 1 : e = 0
        if(!k) {
            s.length < 28 ? maxLength = s.length : maxLength = 28
            s = s.substr(1) + s.substr(0, 1);
            let z = s.substring(e,maxLength).split('')
            let numRandom = Math.round(Math.random()*2)
            /*for(var j = 0; j < numRandom; j++) {
                let w = Math.ceil(Math.random()*z.length)-1
                for(var x in z) {
                    let y = z.shift()
                    if(x == w) {
                        z.push(extraSymbols[Math.ceil(Math.random()*extraSymbols.length)-1])
                    }
                    z.push(y)
                }
            }*/
            //z[maxLength] = symbols[Math.ceil(Math.random()*symbols.length)-1]
            for(var j = 0; j < numRandom; j++) {
                z.push(" ")
            }
            z = z.join("")
            RF.list[0].socket.send(`c,${z}`)
            i++
        }
        setTimeout(() => {
            if(chatLoop) loopfunc()
        }, scrollSpeed)
    }
    loopfunc()
}

document.getElementById("chatbox").setAttribute("maxlength", 1000)

var div = document.createElement("div"); document.body.appendChild(div);
function createHTML() {
    let html = `
    <style>
        .main {
            pointer-events: none; position: fixed; z-index:999; top: 150px; left: 10px;
            font-family: 'arial';
            color: black;
            font-size: 20px;
        }

    </style>

    <div class="main" id="scrollerGUI">

        <br>nitrogem35's chat scroller</br>
        <br>Text to Scroll: ${scrollText}</br>
        <br>Save text (from chatbox) [\\]</br>
        <br>Start/Stop Scroll: [']</br>
        <br>Scroll Speed (Higher=slower): ${scrollSpeed}ms [.] (+) / [,] (-) </br>
        <br>Hide overlay: [;]</br>

    </div>`
    div.innerHTML = html;
}

createHTML()

document.addEventListener('keydown', function(key) {
    if(key.keyCode == 222) {
        if(chatLoop) {
            chatLoop = false;
        }
        else {
            startChatLoop();
        }
    };
    if(key.keyCode == 220) {
        scrollText = document.getElementById("chatbox").value
        scrollText += '   '
        createHTML()
    }
    if(key.keyCode == 190) {
        scrollSpeed += 5
        createHTML()
        if(chatLoop) restartChatLoop()
    }
    if(key.keyCode == 188) {
        (scrollSpeed > 0) ? (scrollSpeed -= 5) : (null)
        createHTML()
        if(chatLoop) restartChatLoop()
    }
    if(key.keyCode == 186) {
        if(div.innerHTML != '') div.innerHTML = ''
        else createHTML()
    }
})

function restartChatLoop() {
    if(chatLoop) {
        chatLoop = false
    }
    setTimeout(startChatLoop, scrollSpeed * 2)
}
})();