Listens for postMessage events on playground.allenai.org and enters into chat input and sends
当前为
// ==UserScript==
// @name AllenAI Message Listener
// @description Listens for postMessage events on playground.allenai.org and enters into chat input and sends
// @match https://playground.allenai.org/*
// @grant none
// @version 0.0.1.20250511173213
// @namespace https://greasyfork.org/users/1435046
// ==/UserScript==
(function() {
'use strict';
window.addEventListener('message', event => {
const message = event.data;
const textarea = document.querySelector('textarea[name="content"], textarea[aria-label="Message OLMo"]');
if (!textarea) return;
// Set value and trigger React update
textarea.value = message;
textarea.dispatchEvent(new Event('input', { bubbles: true }));
// Wait one animation frame so the UI registers the input
requestAnimationFrame(() => {
const sendBtn = document.querySelector('button[type="submit"][aria-label="Submit prompt"]');
if (sendBtn) sendBtn.click();
});
});
})();