DiscordTokenLogin

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

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

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

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

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