channel-worker 1.0.23 → 1.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/command-poller.js +15 -1
- package/package.json +1 -1
package/lib/command-poller.js
CHANGED
|
@@ -586,7 +586,21 @@ class CommandPoller {
|
|
|
586
586
|
|
|
587
587
|
ws.on('open', async () => {
|
|
588
588
|
try {
|
|
589
|
-
|
|
589
|
+
await send('DOM.enable');
|
|
590
|
+
// Focus the contenteditable editor via CDP
|
|
591
|
+
await send('Runtime.evaluate', {
|
|
592
|
+
expression: `
|
|
593
|
+
const editors = document.querySelectorAll('[contenteditable="true"], [role="textbox"]');
|
|
594
|
+
let focused = false;
|
|
595
|
+
for (const e of editors) {
|
|
596
|
+
if (e.offsetHeight >= 15) { e.focus(); e.click(); focused = true; break; }
|
|
597
|
+
}
|
|
598
|
+
focused ? 'focused' : 'no_editor'
|
|
599
|
+
`,
|
|
600
|
+
});
|
|
601
|
+
// Small delay for focus to take effect
|
|
602
|
+
await new Promise(r => setTimeout(r, 300));
|
|
603
|
+
// Type text
|
|
590
604
|
await send('Input.insertText', { text });
|
|
591
605
|
ws.close();
|
|
592
606
|
resolve({ success: true, length: text.length });
|