Login Via Token

Adds a button to the login screen for your token. This one actually works and looks good

Szkript telepítése?
A szerző által javasolt szkript

Ez is érdekelhet: Emmet's Direct Factorio Mods Downloader 2025

Szkript telepítése
// ==UserScript==
// @name         Login Via Token
// @namespace    https://v15.studio/
// @version      v69.420.3
// @description  Adds a button to the login screen for your token. This one actually works and looks good
// @author       Emmet_v15
// @license      BSD
// @match        *://discord.com/login*
// @grant        none
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @run-at       document-end
// ==/UserScript==

function waitForElm(selector) {
    return new Promise(resolve => {
        if (document.querySelector(selector)) {
            return resolve(document.querySelector(selector));
        }

        const observer = new MutationObserver(mutations => {
            if (document.querySelector(selector)) {
                resolve(document.querySelector(selector));
                observer.disconnect();
            }
        });

        observer.observe(document.body, {
            childList: true,
            subtree: true
        });
    });
}
waitForElm('button[type="submit"][class*="button__"]').then((elm) => {
    // Create custom button by cloning the submit button
    const customButton = elm.cloneNode(true);
    customButton.id = 'tokenLoginBtn';
    customButton.type = 'button'; // Prevent form submission
    const buttonText = customButton.querySelector('[class*="contents__"]');
    if (buttonText) buttonText.textContent = 'Log In Via Token';

    // Get the password field as a template
    const passwordField = document.querySelector('[name="password"]');
    const fieldWrapper = passwordField.closest('[class*="fieldWrapper"]');

    // Create token field HTML using the password field's structure
    const tokenFieldHTML = fieldWrapper.outerHTML
        .replace(/password/g, 'token')
        .replace(/Password/g, 'Token')
        .replace(/uid_\d+/g, 'tokenInput')
        .replace(/:r\d+:/g, 'tokenLabel');

    // Create a container div and add both elements
    const container = document.createElement('div');
    container.innerHTML = tokenFieldHTML;
    const tokenField = container.firstChild;

    // Add margin bottom - look for existing margin class or use inline style
    const marginClass = document.querySelector('[class*="marginBottom20"]').className.match(/marginBottom20\S+/)[0];
    if (marginClass) {
        tokenField.classList.add(marginClass);
    } else {
        tokenField.style.marginBottom = '20px';
    }

    // Insert token field first, then button
    elm.parentNode.insertBefore(tokenField, elm.nextSibling);
    elm.parentNode.insertBefore(customButton, tokenField.nextSibling);

    // Add click handler
    customButton.addEventListener('click', function() {
        const token = document.getElementById('tokenInput').value;
        const iframe = document.body.appendChild(document.createElement('iframe'));
        iframe.contentWindow.localStorage.token = `"${token}"`;
        window.location.reload();
    });
});