Kahoot Namerator and Name Length Bypass

Bypasses kahoot nickname generator as well as the maximum name length

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name        Kahoot Namerator and Name Length Bypass
// @author      slither
// @version     2.3.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;

                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 (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 input = document.createElement("input");
                const nickname = document.getElementById("nickname");
                const reactProps = Object.keys(nickname).find(v => v.includes("__reactProps"));
                input.className = nickname.className;
                input.type = "text";
                input.placeholder = "Nickname";
                nickname.replaceWith(input);

                input.nextElementSibling.addEventListener("click", function() {
                    nick = input.value;
                    nickname[reactProps].onChange({ target: { value: nick.slice(0, 15) } });
                });

                observer.disconnect();
            }
        });

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

    return ret;
};