channel-worker 1.0.25 → 1.0.26
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 +9 -3
- package/package.json +1 -1
package/lib/command-poller.js
CHANGED
|
@@ -550,7 +550,7 @@ class CommandPoller {
|
|
|
550
550
|
}
|
|
551
551
|
|
|
552
552
|
async handleTypeText(command) {
|
|
553
|
-
const { text, profile_id, url_match } = command.payload || {};
|
|
553
|
+
const { text, profile_id, url_match, focus_selector } = command.payload || {};
|
|
554
554
|
console.log(`[commands] Typing text (${text?.length} chars) for profile: ${profile_id}`);
|
|
555
555
|
try {
|
|
556
556
|
const WebSocket = require('ws');
|
|
@@ -587,11 +587,17 @@ class CommandPoller {
|
|
|
587
587
|
ws.on('open', async () => {
|
|
588
588
|
try {
|
|
589
589
|
await send('DOM.enable');
|
|
590
|
-
// Focus
|
|
590
|
+
// Focus target element via CDP
|
|
591
|
+
const sel = (focus_selector || '').replace(/'/g, "\\'");
|
|
591
592
|
const focusResult = await send('Runtime.evaluate', {
|
|
592
593
|
expression: `
|
|
593
594
|
(function() {
|
|
594
|
-
//
|
|
595
|
+
// Use specific selector if provided
|
|
596
|
+
if ('${sel}') {
|
|
597
|
+
const el = document.querySelector('${sel}');
|
|
598
|
+
if (el) { el.focus(); el.click(); return 'focused_selector: ${sel}'; }
|
|
599
|
+
}
|
|
600
|
+
// Try dialog editor
|
|
595
601
|
const dialog = document.querySelector('[role="dialog"]');
|
|
596
602
|
if (dialog) {
|
|
597
603
|
const editor = dialog.querySelector('[contenteditable="true"], [role="textbox"]');
|