Greasy Fork

Greasy Fork is available in English.

Paste to Grok Textarea

Paste text into Grok textarea from main page

目前为 2025-05-16 提交的版本,查看 最新版本

// ==UserScript==
// @name         Paste to Grok Textarea
// @description  Paste text into Grok textarea from main page
// @match        *://grok.com/*
// @version 0.0.1.20250516072640
// @namespace http://greasyfork.icu/users/1435046
// ==/UserScript==

(function () {
    'use strict';

    // Listen for messages from parent
    window.addEventListener("message", event => {
        const data = event.data;
        if (typeof data === "string" && data.trim()) {
            // Try to find the Grok textarea
            const textarea = document.querySelector('textarea[aria-label="Ask Grok anything"]');
            if (textarea) {
                textarea.focus();
                textarea.value = data;
                // Dispatch input event so React sees the change
                textarea.dispatchEvent(new Event("input", { bubbles: true }));
            }
        }
    });
})();