DiscordTokenLogin

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

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==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();
            }
        })
    })
})();