// ==UserScript== // @name AllenAI Auto-Submit Listener // @description Listens for postMessage events on playground.allenai.org, enters into chat input, and auto-submits // @match https://playground.allenai.org/* // @version 0.0.1.20250516101342 // @namespace https://greasyfork.org/users/1435046 // @downloadURL https://update.greasyfork.icu/scripts/535679/AllenAI%20Auto-Submit%20Listener.user.js // @updateURL https://update.greasyfork.icu/scripts/535679/AllenAI%20Auto-Submit%20Listener.meta.js // ==/UserScript== (function() { 'use strict'; function setNativeValue(element, value) { const lastValue = element.value; element.value = value; const tracker = element._valueTracker; if (tracker) { tracker.setValue(lastValue); } element.dispatchEvent(new Event('input', { bubbles: true })); } window.addEventListener('message', event => { if (event.data?.type === 'newChatButtonClicked') { const newChatLink = document.querySelector('a[aria-label="Create a new thread"]'); if (newChatLink) { newChatLink.click(); } return; } if (event.data.type !== 'prompt' || event.data.content === 'recaptcha-setup') return; const message = event.data.content; // find the MUI/React textarea const textarea = document.querySelector( 'textarea[name="content"], textarea[aria-label="Message OLMo"]' ); if (!textarea) return; // inject into React state setNativeValue(textarea, message); // find and click the submit button const sendButton = document.querySelector('button[aria-label="Submit prompt"]'); if (sendButton) { sendButton.click(); } }); })();