Kahoot Namerator and Name Length Bypass

Bypasses kahoot nickname generator as well as the maximum name length

当前为 2023-05-30 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Kahoot Namerator and Name Length Bypass
// @author      slither
// @version     2.2.0
// @license     MIT
// @description Bypasses kahoot nickname generator as well as the maximum name length
// @match       https://kahoot.it/*
// @grant       none
// @run-at      document-start
// @namespace   https://greasyfork.org/users/964173
// ==/UserScript==

let nick = "";

const nativeSend = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function() {
    const oldCallback = this.onreadystatechange;

    this.onreadystatechange = function() {
        if (this.readyState === 4) {
            try {
                const response = JSON.parse(this.responseText);

                if (response.namerator === true) {
                    response.namerator = false;
                    alert("Namerator Bypassed!");
                }

                Object.defineProperty(this, "responseText",{
                    writable: false,
                    configurable: true,
                    value: JSON.stringify(response)
                });
            } catch (e) {
                console.error(e);
            }
        }

        if (oldCallback)
            return oldCallback.apply(this, arguments);
    };

    return nativeSend.apply(this, arguments);
};

const nativeWebSocket = window.WebSocket;
window.WebSocket = function() {
    const ws = new nativeWebSocket(...arguments);
    const nativeSend = ws.send;

    ws.send = function() {
        const interceptedMessage = JSON.parse(arguments[0]);

        if (interceptedMessage[0] && interceptedMessage[0].data) {
            if (interceptedMessage[0].content && JSON.parse(interceptedMessage[0].data.content).usingNamerator === false)
                interceptedMessage[0].data.content = JSON.stringify({...JSON.parse(interceptedMessage[0].data.content), usingNamerator: true});

            if (nick && interceptedMessage[0].data.name) {
                interceptedMessage[0].data.name = nick;
                nick = "";
            }
        }

        return nativeSend.apply(this, [JSON.stringify(interceptedMessage)]);
    };

    return ws;
};

const nativePushState = history.pushState;
history.pushState = function() {
    const ret = nativePushState.apply(history, arguments);

    if (location.href.includes("kahoot.it/join")) {
        const observer = new MutationObserver(function() {
            if (document.getElementById("nickname")) {
                const nickname = document.getElementById("nickname");
                nickname.removeAttribute("maxlength");

                document.querySelector("button").addEventListener("click", function() {
                    nick = nickname.value;
                    if (nick.length > 15)
                        nickname[Object.keys(nickname).find(v => v.includes("__reactProps"))].onChange({target: {value: "Limit Bypassed!"}});
                });

                observer.disconnect();
            }
        });

        observer.observe(document.body, {
            childList: true,
            subtree: true
        });
    }

    return ret;
};