From d793c19a725b4cd53f6a18c7f832b32733ca1975 Mon Sep 17 00:00:00 2001 From: threenrm Date: Wed, 21 Jan 2026 18:21:36 +0800 Subject: [PATCH] fix: use CDP Input.insertText for reliable text insertion The previous document.execCommand('insertText') caused text to be duplicated multiple times. Switch to CDP's Input.insertText for more reliable text input. Co-Authored-By: Claude Opus 4.5 --- skills/baoyu-post-to-x/scripts/x-quote.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/skills/baoyu-post-to-x/scripts/x-quote.ts b/skills/baoyu-post-to-x/scripts/x-quote.ts index 0703c50..4acf1ea 100644 --- a/skills/baoyu-post-to-x/scripts/x-quote.ts +++ b/skills/baoyu-post-to-x/scripts/x-quote.ts @@ -310,15 +310,14 @@ export async function quotePost(options: QuoteOptions): Promise { // Type the comment if provided if (comment) { console.log('[x-quote] Typing comment...'); - const commentJson = JSON.stringify(comment); + // Use CDP Input.insertText for more reliable text insertion await cdp.send('Runtime.evaluate', { - expression: ` - const editor = document.querySelector('[data-testid="tweetTextarea_0"]'); - if (editor) { - editor.focus(); - document.execCommand('insertText', false, ${commentJson}); - } - `, + expression: `document.querySelector('[data-testid="tweetTextarea_0"]')?.focus()`, + }, { sessionId }); + await sleep(200); + + await cdp.send('Input.insertText', { + text: comment, }, { sessionId }); await sleep(500); }