Greasy Fork is available in English.

Paste Essays (Acellus)

Essays are dead to me

질문, 리뷰하거나, 이 스크립트를 신고하세요.
// ==UserScript==
// @name         Paste Essays (Acellus)
// @namespace    https://greasyfork.org/en/users/1291009
// @version      1.0
// @description  Essays are dead to me
// @author       BadOrBest
// @license      MIT
// @icon         https://www.google.com/s2/favicons?sz=64&domain=acellus.com
// @match        https://admin192c.acellus.com/student/*
// @grant        none
// @grant        GM_addStyle
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_deleteValue
// @run-at       document-end
// ==/UserScript==
(function() {
    'use strict';

    // Define the text to be typed
    var textToType = "Paste here";

     // Function to simulate typing as a user
    function typeTextAsUser(element, text) {
        var index = 0;
        var event = new KeyboardEvent('keydown', { key: '', code: '' });
        var inputEvent = new Event('input', { bubbles: true });

        var interval = setInterval(function() {
            // Simulate typing one character at a time
            element.textContent += text.charAt(index);
            element.dispatchEvent(inputEvent);
            element.dispatchEvent(event);
            index++;

            // Stop typing when text is fully typed
            if (index >= text.length) {
                clearInterval(interval);
            }
        }, 5); // Very fast typing speed
    }

    // Function to open the popup
    function openPopup() {
        var editedText = prompt("Edit text:", textToType);
        if (editedText !== null) {
            textToType = editedText;
            typeTextAsUser(document.activeElement, textToType); // Start typing with the updated text
        }
    }

    // Add event listener for when text inputs gain focus
    document.addEventListener('click', function(event) {
        var target = event.target;
        if (target.contentEditable === 'true') {
            openPopup();
        }
    }, true); // Use capture phase to ensure event is caught before any other handlers

})();