DiscordTokenLogin

Adds an option to login to discord via a token from the clipboard

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         DiscordTokenLogin
// @namespace    http://tampermonkey.net/
// @version      0.9
// @description  Adds an option to login to discord via a token from the clipboard
// @author       idjawoo
// @match        *://discord.com/login
// @run-at       document-end
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function waitForElm(selector) {
        return new Promise((resolve) => {
            if (document.querySelector(selector)) {
                return resolve(document.querySelector(selector));
            }

            const observer = new MutationObserver(() => {
                if (document.querySelector(selector)) {
                    resolve(document.querySelector(selector));
                    observer.disconnect();
                }
            });

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


    window.addEventListener('load', function () {
        waitForElm("button[type='submit']").then((result) => {
            var button = result
            var tokenButton = button.cloneNode(true)
            var buttonstack = document.getElementsByTagName("form")[0].children[1].children[0].children[0]
            var wrap = document.createElement('div');

            wrap.style.width = "100%"
            tokenButton.style.cursor = "pointer"
            tokenButton.innerHTML = "Use Token"
            tokenButton.type = "button"
            tokenButton.addEventListener (
                "click", ButtonClickAction, false
            );

            wrap.appendChild(tokenButton);
            wrap.style.marginTop = "20px"

            buttonstack.appendChild(wrap)
            function ButtonClickAction(event) {
                navigator.clipboard.readText()
                    .then(text => {
                    login(text);
                }).catch(error => {
                    console.error('Error whilst reading clipboard: ', error);
                });
            }

            function login(token) {
                document.body.appendChild(document.createElement `iframe`).contentWindow.localStorage.token = `"${token}"`
                location.reload();
            }
        })
    })
})();