Greasy Fork is available in English.
a
当前为
// ==UserScript==
// @name Mistral Chat Receiver
// @description a
// @match https://chat.mistral.ai/*
// @run-at document-idle
// @version 0.0.1.20250520202747
// @namespace http://greasyfork.icu/users/1435046
// ==/UserScript==
(() => {
/* first principles: a Window object dispatches a “message” event
whenever another browsing context calls window.postMessage(...)
on it. We capture that single bubbling event here. */
window.addEventListener('message', e => {
const { type, content } = e.data; // structured-clone payload
if (type !== 'prompt') return; // we only care about prompts
/* textarea = text + area (Latin “textum” + Greek “aer” > “area”):
an HTML control for multi-line plain-text input. */
const ta = document.querySelector('textarea[name="message.text"]');
ta.value = content; // paste
ta.dispatchEvent(new Event('input', { bubbles: true })); // make the UI notice
/* Simulate the Return keystroke so Mistral actually sends.
“Event” comes from Latin “eventus”, meaning a happening;
“dispatch” from Latin “dis-” + “pactum”, to send in different
directions. */
ta.dispatchEvent(new KeyboardEvent('keydown', {
key: 'Enter',
bubbles: true
}));
});
})();