Greasy Fork is available in English.

authorization Extractor

Extract Discord Token and display it in a draggable and resizable box without popups

// ==UserScript==
// @name         authorization Extractor
// @namespace    http://tampermonkey.net/
// @version      1.3
// @description  Extract Discord Token and display it in a draggable and resizable box without popups
// @author       Your Name
// @match        https://discord.com/*
// @grant        none
// @license      You can modify as long as you credit me
// ==/UserScript==
 
(function() {
    'use strict';
 
    function makeElementDraggable(el) {
        el.onmousedown = function(event) {
            event.preventDefault();
 
            let shiftX = event.clientX - el.getBoundingClientRect().left;
            let shiftY = event.clientY - el.getBoundingClientRect().top;
 
            function moveAt(pageX, pageY) {
                el.style.left = Math.min(Math.max(0, pageX - shiftX), window.innerWidth - el.offsetWidth) + 'px';
                el.style.top = Math.min(Math.max(0, pageY - shiftY), window.innerHeight - el.offsetHeight) + 'px';
            }
 
            function onMouseMove(event) {
                moveAt(event.pageX, event.pageY);
            }
 
            document.addEventListener('mousemove', onMouseMove);

            function onMouseUp() {
                document.removeEventListener('mousemove', onMouseMove);
                document.removeEventListener('mouseup', onMouseUp);
            }

            document.addEventListener('mouseup', onMouseUp);
        };
 
        el.ondragstart = function() {
            return false;
        };
    }
 
    function addResizeButtons(el, initialWidth, initialHeight) {
        const buttonContainer = document.createElement('div');
        buttonContainer.style.position = 'absolute';
        buttonContainer.style.right = '10px';
        buttonContainer.style.top = '10px';
        buttonContainer.style.display = 'flex';
        buttonContainer.style.flexDirection = 'column';
        buttonContainer.style.gap = '10px';
        el.appendChild(buttonContainer);
    }
 
    function getToken() {
        let token = localStorage.getItem('token');
        if (!token) {
            alert("Discordのトークンが見つかりませんでした。");
            return;
        }
        token = token.slice(1, -1);
 
        const initialWidth = '300px';
        const initialHeight = '200px';
 
        const container = document.createElement('div');
        container.id = 'tokenContainer';
        container.style.position = 'fixed';
        container.style.top = '10px';
        container.style.left = '10px';
        container.style.backgroundColor = '#2f3136';
        container.style.color = '#ffffff';
        container.style.padding = '20px';
        container.style.borderRadius = '5px';
        container.style.zIndex = '1000';
        container.style.width = initialWidth;
        container.style.height = initialHeight;
        container.style.overflowY = 'auto';
        document.body.appendChild(container);
 
        makeElementDraggable(container);
        addResizeButtons(container, initialWidth, initialHeight);
 
        const title = document.createElement('h2');
        title.textContent = 'authorization';
        title.style.margin = '0 0 10px 0';
        title.style.fontSize = '16px';
        container.appendChild(title);
 
        const tokenDisplay = document.createElement('code');
        tokenDisplay.textContent = token;
        tokenDisplay.style.whiteSpace = 'pre-wrap';
        tokenDisplay.style.wordBreak = 'break-word';
        tokenDisplay.style.display = 'block';
        tokenDisplay.style.marginBottom = '10px';
        container.appendChild(tokenDisplay);
 
        const copyButton = document.createElement('button');
        copyButton.textContent = 'Copy';
        copyButton.style.padding = '10px';
        copyButton.style.backgroundColor = '#7289da';
        copyButton.style.color = '#ffffff';
        copyButton.style.border = 'none';
        copyButton.style.borderRadius = '3px';
        copyButton.style.cursor = 'pointer';
        container.appendChild(copyButton);
 
        const toggleVisibilityButton = document.createElement('button');
        toggleVisibilityButton.textContent = '🔒 Show/Hide';
        toggleVisibilityButton.style.padding = '10px';
        toggleVisibilityButton.style.backgroundColor = '#ff9800';
        toggleVisibilityButton.style.color = '#ffffff';
        toggleVisibilityButton.style.border = 'none';
        toggleVisibilityButton.style.borderRadius = '3px';
        toggleVisibilityButton.style.cursor = 'pointer';
        container.appendChild(toggleVisibilityButton);
 
        let tokenVisible = true;
        toggleVisibilityButton.addEventListener('click', () => {
            if (tokenVisible) {
                tokenDisplay.textContent = '•'.repeat(token.length);
            } else {
                tokenDisplay.textContent = token;
            }
            tokenVisible = !tokenVisible;
        });
 
        copyButton.addEventListener('click', function() {
            const dummy = document.createElement('textarea');
            document.body.appendChild(dummy);
            dummy.value = token;
            dummy.select();
            document.execCommand('copy');
            document.body.removeChild(dummy);
            alert("copied your authorization to clipboard.");
        });
    }
 
    getToken();
})();