Discord Token Getter

Gets your token on discord.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Discord Token Getter
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  Gets your token on discord.
// @author       You
// @match        https://*.discord.com/@me*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    window.onload = function() {
        let popup;
        popup = window.open('');
        if (!popup) return alert('Popup blocked! Please allow popups and try again.');
        popup.document.write("Getting token...")
        window.dispatchEvent(new Event('beforeunload'));
        window.tkn = JSON.parse(popup.localStorage.token);
        popup.close()
    }

    setInterval(function() {
        let userInfo = document.querySelector('div div[class*="children-"] div[class*="background-"] div[class*="fieldList"]');
        if(!userInfo) return;

        let editButton = userInfo.querySelector('button[class*="fieldButton-"]')

        let tokenField = document.getElementById("get-token-field");
        if(tokenField) {
            if(editButton) {
                tokenField.style.display = "";
            } else {
                tokenField.style.display = "none";
            }
            return;
        };

        tokenField = document.createElement("div")
        tokenField.id = "get-token-field"
        tokenField.className = editButton.parentElement.nextElementSibling.className

        let constrainedRow = document.createElement("div")
        constrainedRow.className = userInfo.querySelector('div[class*="constrainedRow-"]').className

        let tokenFieldTitle = document.createElement("h5")
        tokenFieldTitle.innerHTML = "TOKEN"
        tokenFieldTitle.className = editButton.parentElement.querySelector('h5').className

        let tokenFieldContent = document.createElement("span")
        tokenFieldContent.innerHTML = "Token"
        tokenFieldContent.className = editButton.parentElement.querySelector('div div span[class*="colorHeaderPrimary"]').className

        constrainedRow.appendChild(document.createElement("div")).appendChild(tokenFieldTitle).parentElement.appendChild(document.createElement("div")).appendChild(tokenFieldContent)
        tokenField.appendChild(constrainedRow)

        let fieldButtonList = document.createElement("div")
        fieldButtonList.className = userInfo.querySelector('div[class*="fieldButtonList"]').className

        let tokenFieldCopy = document.createElement("button")
        tokenFieldCopy.onclick = function() {
            if(tkn) {
                let tkn2 = tkn.split('')
                tkn2.shift()
                tkn2.pop()
                tkn2 = tkn2.join('')

                let popup = window.open("")

                popup.document.body.innerHTML = `Your token is <input placeholder="Token" readonly>.<br>To reset it, change your username or password.`
                popup.eval(`document.querySelector('input').value = "${tkn2}"`)
                popup.eval(`document.querySelector('input').onclick = function() {
                    let copy = document.querySelector('input')
                    copy.select();
                    copy.setSelectionRange(0, 99999);
                    document.execCommand("copy");

                    let token = copy.value
                    copy.value = "Copied!"

                    setTimeout(function() {
                        copy.value = token
                    }, 1000)
                }`)
            } else {
                alert("Error getting token. Please try again.")
            }
        }
        tokenFieldCopy.innerHTML = "Get"
        tokenFieldCopy.className = editButton.className
        fieldButtonList.appendChild(tokenFieldCopy)

        tokenField.appendChild(fieldButtonList)

        userInfo.appendChild(tokenField)
    }, 50)
})();