Discord UID Extractor

Extract UIDs from Discord avatars and display them

目前為 2024-11-23 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Discord UID Extractor
// @namespace    http://tampermonkey.net/
// @version      1.7
// @description  Extract UIDs from Discord avatars and display them
// @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 = pageX - shiftX + 'px';
                el.style.top = pageY - shiftY + 'px';
            }

            function onMouseMove(event) {
                moveAt(event.pageX, event.pageY);
            }

            document.addEventListener('mousemove', onMouseMove);

            el.onmouseup = function() {
                document.removeEventListener('mousemove', onMouseMove);
                el.onmouseup = null;
            };
        };

        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.bottom = '10px';
        buttonContainer.style.display = 'flex';
        buttonContainer.style.flexDirection = 'column';
        buttonContainer.style.gap = '10px';
        el.appendChild(buttonContainer);

        const enlargeButton = document.createElement('button');
        enlargeButton.textContent = '🔍+';
        enlargeButton.style.padding = '5px 10px';
        enlargeButton.style.backgroundColor = '#4CAF50';
        enlargeButton.style.color = '#ffffff';
        enlargeButton.style.border = 'none';
        enlargeButton.style.borderRadius = '3px';
        enlargeButton.style.cursor = 'pointer';
        buttonContainer.appendChild(enlargeButton);

        const shrinkButton = document.createElement('button');
        shrinkButton.textContent = '🔍-';
        shrinkButton.style.padding = '5px 10px';
        shrinkButton.style.backgroundColor = '#f44336';
        shrinkButton.style.color = '#ffffff';
        shrinkButton.style.border = 'none';
        shrinkButton.style.borderRadius = '3px';
        shrinkButton.style.cursor = 'pointer';
        buttonContainer.appendChild(shrinkButton);

        enlargeButton.addEventListener('click', () => {
            el.style.height = (el.clientHeight + 20) + 'px';
        });

        shrinkButton.addEventListener('click', () => {
            el.style.width = initialWidth; 
            el.style.height = initialHeight; 
        });
    }

    
    const initialWidth = '280px';
    const initialHeight = '80px';

    
    const container = document.createElement('div');
    container.style.position = 'fixed';
    container.style.top = '10px';
    container.style.left = '10px';
    container.style.backgroundColor = '#2f3136';
    container.style.color = '#ffffff';
    container.style.padding = '10px';
    container.style.borderRadius = '5px';
    container.style.zIndex = '1000';
    container.style.width = initialWidth;
    container.style.height = initialHeight;
    container.style.overflowY = 'scroll';
    document.body.appendChild(container);

    
    makeElementDraggable(container);

    
    addResizeButtons(container, initialWidth, initialHeight);

   
    const title = document.createElement('h2');
    title.textContent = 'Extracted UIDs';
    title.style.margin = '0 0 10px 0';
    title.style.fontSize = '16px';
    container.appendChild(title);

    
    const uidList = document.createElement('ul');
    uidList.style.listStyleType = 'none';
    uidList.style.padding = '0';
    container.appendChild(uidList);

    
    const startButton = document.createElement('button');
    startButton.textContent = 'Start Extraction';
    startButton.style.marginTop = '10px';
    startButton.style.padding = '5px 10px';
    startButton.style.backgroundColor = '#7289da';
    startButton.style.color = '#ffffff';
    startButton.style.border = 'none';
    startButton.style.borderRadius = '3px';
    startButton.style.cursor = 'pointer';
    container.appendChild(startButton);

    
    const copyButton = document.createElement('button');
    copyButton.textContent = 'Copy UIDs';
    copyButton.style.marginTop = '10px';
    copyButton.style.padding = '5px 10px';
    copyButton.style.backgroundColor = '#7289da';
    copyButton.style.color = '#ffffff';
    copyButton.style.border = 'none';
    copyButton.style.borderRadius = '3px';
    copyButton.style.cursor = 'pointer';
    container.appendChild(copyButton);

    
    function extractUIDs() {
        const avatarElements = document.querySelectorAll('img[src*="cdn.discordapp.com/avatars/"]');
        const uids = new Set();
        avatarElements.forEach(img => {
            const url = img.src;
            const match = url.match(/avatars\/(\d+)\//);
            if (match) {
                uids.add(match[1]);
            }
        });
        return Array.from(uids);
    }

    
    function updateUIDList() {
        const uids = extractUIDs();
        uids.forEach(uid => {
            if (!Array.from(uidList.children).some(li => li.textContent === uid)) {
                const listItem = document.createElement('li');
                listItem.textContent = uid;
                uidList.appendChild(listItem);
            }
        });
    }

    
    function copyUIDsToClipboard() {
        const uids = Array.from(uidList.children).map(li => li.textContent).join('\n');
        navigator.clipboard.writeText(uids).then(() => {
        }).catch(err => {
            console.error('Failed to copy UIDs: ', err);
        });
    }

    
    startButton.addEventListener('click', () => {
        updateUIDList();
        const observer = new MutationObserver(() => {
            setTimeout(updateUIDList, 1000);
        });
        observer.observe(document.body, { childList: true, subtree: true });
    });

    
    copyButton.addEventListener('click', copyUIDsToClipboard);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址