Ahmad Kholid 1 year ago
parent
commit
a0af454204

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "automa",
   "name": "automa",
-  "version": "1.28.14",
+  "version": "1.28.15",
   "description": "An extension for automating your browser by connecting blocks",
   "description": "An extension for automating your browser by connecting blocks",
   "repository": {
   "repository": {
     "type": "git",
     "type": "git",

+ 2 - 0
src/content/blocksHandler/handlerForms.js

@@ -24,6 +24,8 @@ async function forms(block) {
 
 
   async function typeText(element) {
   async function typeText(element) {
     if (block.debugMode && data.type === 'text-field') {
     if (block.debugMode && data.type === 'text-field') {
+      element.focus?.();
+
       const commands = data.value.split('').map((char) => ({
       const commands = data.value.split('').map((char) => ({
         type: 'keyDown',
         type: 'keyDown',
         text: char === '\n' ? '\r' : char,
         text: char === '\n' ? '\r' : char,

+ 16 - 17
src/content/services/shortcutListener.js

@@ -7,23 +7,22 @@ Mousetrap.prototype.stopCallback = function () {
 };
 };
 
 
 function automaCustomEventListener(findWorkflow) {
 function automaCustomEventListener(findWorkflow) {
-  window.addEventListener(
-    'automa:execute-workflow',
-    ({ detail }) => {
-      if (!detail || (!detail.id && !detail.publicId)) return;
-
-      const workflowId = detail.id || detail.publicId;
-      const workflow = findWorkflow(workflowId, Boolean(detail.publicId));
-
-      if (!workflow) return;
-
-      workflow.options = {
-        data: detail.data || {},
-      };
-      sendMessage('workflow:execute', workflow, 'background');
-    },
-    true
-  );
+  function customEventListener({ detail }) {
+    if (!detail || (!detail.id && !detail.publicId)) return;
+
+    const workflowId = detail.id || detail.publicId;
+    const workflow = findWorkflow(workflowId, Boolean(detail.publicId));
+
+    if (!workflow) return;
+
+    workflow.options = {
+      data: detail.data || {},
+    };
+    sendMessage('workflow:execute', workflow, 'background');
+  }
+
+  window.addEventListener('__automaExecuteWorkflow', customEventListener);
+  window.addEventListener('automa:execute-workflow', customEventListener);
 }
 }
 function workflowShortcutsListener(findWorkflow, shortcutsObj) {
 function workflowShortcutsListener(findWorkflow, shortcutsObj) {
   const shortcuts = Object.entries(shortcutsObj);
   const shortcuts = Object.entries(shortcutsObj);

+ 2 - 0
src/utils/shared.js

@@ -782,6 +782,7 @@ export const tasks = {
     refDataKeys: [
     refDataKeys: [
       'maxLoop',
       'maxLoop',
       'loopData',
       'loopData',
+      'selector',
       'startIndex',
       'startIndex',
       'variableName',
       'variableName',
       'referenceKey',
       'referenceKey',
@@ -819,6 +820,7 @@ export const tasks = {
     maxConnection: 1,
     maxConnection: 1,
     refDataKeys: [
     refDataKeys: [
       'maxLoop',
       'maxLoop',
+      'selector',
       'variableName',
       'variableName',
       'elementSelector',
       'elementSelector',
       'actionElSelector',
       'actionElSelector',

+ 2 - 11
src/workflowEngine/helper.js

@@ -65,17 +65,8 @@ export function attachDebugger(tabId, prevTab) {
     if (prevTab && tabId !== prevTab)
     if (prevTab && tabId !== prevTab)
       chrome.debugger.detach({ tabId: prevTab });
       chrome.debugger.detach({ tabId: prevTab });
 
 
-    chrome.debugger.getTargets((targets) => {
-      targets.forEach((target) => {
-        if (target.attached || target.tabId !== tabId) {
-          resolve();
-          return;
-        }
-
-        chrome.debugger.attach({ tabId }, '1.3', () => {
-          chrome.debugger.sendCommand({ tabId }, 'Page.enable', resolve);
-        });
-      });
+    chrome.debugger.attach({ tabId }, '1.3', () => {
+      chrome.debugger.sendCommand({ tabId }, 'Page.enable', resolve);
     });
     });
   });
   });
 }
 }