// ==UserScript== // @name 豆包 Firefox 图片粘贴修复 // @namespace doubao-Firefox-image-fix // @version 0.0.1 // @description 修复豆包Firefox图片粘贴 // @author wxory // @match https://www.doubao.com/* // @run-at document-start // @grant none // @noframes // @license MIT // ==/UserScript== (() => { 'use strict'; window.addEventListener('paste', (event) => { const target = event.target; if (!(target instanceof HTMLElement) || !(target.isContentEditable || target instanceof HTMLTextAreaElement)) { return; } const clipboard = event.clipboardData; if (!clipboard) return; // 必须在同步事件内取出 File;只保存原始 FileList 引用仍会被清空。 const files = Array.from(clipboard.files); if (!files.some((file) => file.type.startsWith('image/'))) return; // 创建独立的原生 FileList,保持豆包读取 files 时的接口不变。 const snapshot = new DataTransfer(); for (const file of files) { snapshot.items.add(file); } Object.defineProperty(clipboard, 'files', { configurable: true, value: snapshot.files, }); }, { capture: true }); })();