mirror of
https://github.com/JimLiu/baoyu-skills.git
synced 2026-07-21 01:39:48 +08:00
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 <noreply@anthropic.com>
This commit is contained in:
@@ -310,15 +310,14 @@ export async function quotePost(options: QuoteOptions): Promise<void> {
|
|||||||
// Type the comment if provided
|
// Type the comment if provided
|
||||||
if (comment) {
|
if (comment) {
|
||||||
console.log('[x-quote] Typing 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', {
|
await cdp.send('Runtime.evaluate', {
|
||||||
expression: `
|
expression: `document.querySelector('[data-testid="tweetTextarea_0"]')?.focus()`,
|
||||||
const editor = document.querySelector('[data-testid="tweetTextarea_0"]');
|
}, { sessionId });
|
||||||
if (editor) {
|
await sleep(200);
|
||||||
editor.focus();
|
|
||||||
document.execCommand('insertText', false, ${commentJson});
|
await cdp.send('Input.insertText', {
|
||||||
}
|
text: comment,
|
||||||
`,
|
|
||||||
}, { sessionId });
|
}, { sessionId });
|
||||||
await sleep(500);
|
await sleep(500);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user