AllenAI Message Listener

Listens for postMessage events on playground.allenai.org and enters into chat input and sends

目前為 2025-05-11 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name AllenAI Message Listener
  3. // @description Listens for postMessage events on playground.allenai.org and enters into chat input and sends
  4. // @match https://playground.allenai.org/*
  5. // @grant none
  6. // @version 0.0.1.20250511173213
  7. // @namespace https://greasyfork.org/users/1435046
  8. // ==/UserScript==
  9.  
  10. (function() {
  11. 'use strict';
  12.  
  13. window.addEventListener('message', event => {
  14. const message = event.data;
  15.  
  16. const textarea = document.querySelector('textarea[name="content"], textarea[aria-label="Message OLMo"]');
  17. if (!textarea) return;
  18.  
  19. // Set value and trigger React update
  20. textarea.value = message;
  21. textarea.dispatchEvent(new Event('input', { bubbles: true }));
  22.  
  23. // Wait one animation frame so the UI registers the input
  24. requestAnimationFrame(() => {
  25. const sendBtn = document.querySelector('button[type="submit"][aria-label="Submit prompt"]');
  26. if (sendBtn) sendBtn.click();
  27. });
  28. });
  29. })();