Wizardebop "Paste Essays Fast"

⚒ Faster Acellus Essay Paster! ⚒

// ==UserScript==
// @name         Wizardebop "Paste Essays Fast"
// @author       Type Stuff
// @description  ⚒ Faster Acellus Essay Paster! ⚒
// @version      1.1
// @match        https://admin192a.acellus.com/student/*
// @match        https://admin192c.acellus.com/student/*
// @license      MIT
// @run-at       document-start
// @grant        none
// @namespace    https://greasyfork.org/users/1394549
// @icon         https://img.freepik.com/free-vector/halloween-witch-hat-isolated-illustration_18591-83719.jpg
// ==/UserScript==

(function () {
    'use strict';

    let lastFocusedElement = null;

    const overlay = document.createElement('div');
    overlay.id = 'pasteGuiOverlay';
    overlay.innerHTML = `
        <div class="paste-gui">
            <h3 class="paste-header">Paste Anything (Acellus)</h3>
            <textarea id="pasteText" placeholder="Paste here..."></textarea>
            <div class="paste-buttons">
                <button id="pasteNow">Paste Text</button>
                <button id="closeGui">Close</button>
            </div>
        </div>
    `;
    document.body.appendChild(overlay);

    GM_addStyle(`
        #pasteGuiOverlay {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background: white;
            border-radius: 12px;
            padding: 20px;
            box-shadow: 0 0 15px rgba(0,0,0,0.2);
            z-index: 9999;
            display: none;
            max-width: 400px;
            width: 90%;
        }
        .paste-gui {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }
        .paste-header {
            margin: 0;
            font-size: 18px;
            text-align: center;
            color: #fff;
            background: #0077cc;
            padding: 10px;
            border-radius: 8px;
        }
        #pasteText {
            width: 100%;
            height: 120px;
            padding: 10px;
            font-size: 14px;
        }
        .paste-buttons {
            display: flex;
            justify-content: space-between;
        }
        .paste-buttons button {
            padding: 8px 16px;
            background: #0077cc;
            color: #fff;
            border: none;
            border-radius: 8px;
            cursor: pointer;
        }
    `);

    function openGui() {
        overlay.style.display = 'block';
    }

    function closeGui() {
        overlay.style.display = 'none';
    }

    function typeLikeUser(element, text) {
        let index = 0;
        const inputEvent = new Event('input', { bubbles: true });

        const interval = setInterval(() => {
            if (element.isContentEditable) {
                element.textContent += text.charAt(index);
            } else {
                element.value += text.charAt(index);
            }
            element.dispatchEvent(inputEvent);
            index++;
            if (index >= text.length) clearInterval(interval);
        }, 5);
    }

    document.getElementById('pasteNow').addEventListener('click', () => {
        const text = document.getElementById('pasteText').value;
        if (lastFocusedElement) {
            lastFocusedElement.focus();
            typeLikeUser(lastFocusedElement, text);
        }
        closeGui();
    });

    document.getElementById('closeGui').addEventListener('click', closeGui);

    document.addEventListener('click', (e) => {
        const target = e.target;
        if (overlay.contains(target)) return;
        if (
            target.isContentEditable ||
            target.nodeName === 'TEXTAREA' ||
            (target.nodeName === 'INPUT' && target.type === 'text')
        ) {
            lastFocusedElement = target;
            openGui();
        }
    }, true);
})();