@eko-ai/eko 1.0.10 → 1.0.11
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/dist/core/eko.d.ts +3 -2
- package/dist/extension/script/common.js +12 -4
- package/dist/extension/utils.d.ts +1 -1
- package/dist/extension.cjs.js +42 -36
- package/dist/extension.esm.js +42 -36
- package/dist/extension_content_script.js +24 -6
- package/dist/index.cjs.js +8698 -8709
- package/dist/index.d.ts +1 -2
- package/dist/index.esm.js +8699 -8709
- package/dist/models/workflow.d.ts +3 -1
- package/dist/nodejs.cjs.js +24 -6
- package/dist/nodejs.esm.js +24 -6
- package/dist/services/parser/workflow-parser.d.ts +2 -1
- package/dist/services/workflow/generator.d.ts +3 -3
- package/dist/types/action.types.d.ts +2 -0
- package/dist/types/eko.types.d.ts +4 -1
- package/dist/types/llm.types.d.ts +0 -2
- package/dist/web.cjs.js +11 -4
- package/dist/web.esm.js +11 -4
- package/package.json +1 -1
package/dist/core/eko.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { EkoConfig, EkoInvokeParam, Tool, Workflow, WorkflowCallback, NodeOutput } from '../types';
|
|
1
|
+
import { LLMConfig, EkoConfig, EkoInvokeParam, Tool, Workflow, WorkflowCallback, NodeOutput } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Eko core
|
|
4
4
|
*/
|
|
5
5
|
export declare class Eko {
|
|
6
6
|
static tools: Map<string, Tool<any, any>>;
|
|
7
7
|
private llmProvider;
|
|
8
|
+
private ekoConfig;
|
|
8
9
|
private toolRegistry;
|
|
9
10
|
private workflowGeneratorMap;
|
|
10
|
-
constructor(
|
|
11
|
+
constructor(llmConfig: LLMConfig, ekoConfig?: EkoConfig);
|
|
11
12
|
generate(prompt: string, param?: EkoInvokeParam): Promise<Workflow>;
|
|
12
13
|
execute(workflow: Workflow, callback?: WorkflowCallback): Promise<NodeOutput[]>;
|
|
13
14
|
cancel(workflow: Workflow): Promise<void>;
|
|
@@ -88,10 +88,14 @@ eko.click = function(element) {
|
|
|
88
88
|
eko.sendKeys = function(element, str, clear, keypress) {
|
|
89
89
|
element.focus && element.focus()
|
|
90
90
|
if (clear) {
|
|
91
|
-
|
|
92
|
-
element.
|
|
91
|
+
if (element.value == undefined) {
|
|
92
|
+
element.textContent = ''
|
|
93
|
+
} else {
|
|
94
|
+
for (let i = 0; i < element.value.length; i++) {
|
|
95
|
+
element.dispatchEvent(new KeyboardEvent('keydown', { key: 'Backspace' }))
|
|
96
|
+
}
|
|
97
|
+
element.value = ''
|
|
93
98
|
}
|
|
94
|
-
element.value = ''
|
|
95
99
|
}
|
|
96
100
|
if (keypress) {
|
|
97
101
|
Array.from(str).forEach(key => {
|
|
@@ -100,7 +104,11 @@ eko.sendKeys = function(element, str, clear, keypress) {
|
|
|
100
104
|
element.value += str
|
|
101
105
|
element.dispatchEvent(new Event('input'))
|
|
102
106
|
} else {
|
|
103
|
-
element.value
|
|
107
|
+
if (element.value == undefined) {
|
|
108
|
+
element.textContent += str
|
|
109
|
+
} else {
|
|
110
|
+
element.value += str
|
|
111
|
+
}
|
|
104
112
|
element.dispatchEvent(new Event('input', { bubbles: true }))
|
|
105
113
|
}
|
|
106
114
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ExecutionContext } from '../types/action.types';
|
|
2
2
|
export declare function getWindowId(context: ExecutionContext): Promise<number>;
|
|
3
3
|
export declare function getTabId(context: ExecutionContext): Promise<number>;
|
|
4
|
-
export declare function getCurrentTabId(windowId?: number): Promise<number>;
|
|
4
|
+
export declare function getCurrentTabId(windowId?: number | undefined): Promise<number | undefined>;
|
|
5
5
|
export declare function open_new_tab(url: string, newWindow: boolean, windowId?: number): Promise<chrome.tabs.Tab>;
|
|
6
6
|
export declare function executeScript(tabId: number, func: any, args: any[]): Promise<any>;
|
|
7
7
|
export declare function waitForTabComplete(tabId: number, timeout?: number): Promise<chrome.tabs.Tab>;
|
package/dist/extension.cjs.js
CHANGED
|
@@ -30,21 +30,12 @@ async function getWindowId(context) {
|
|
|
30
30
|
async function getTabId(context) {
|
|
31
31
|
let tabId = context.variables.get('tabId');
|
|
32
32
|
if (tabId) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// Check if it's a valid integer
|
|
36
|
-
if (!Number.isInteger(tabId)) {
|
|
37
|
-
context.variables.delete('tabId');
|
|
38
|
-
tabId = null;
|
|
33
|
+
try {
|
|
34
|
+
await chrome.tabs.get(tabId);
|
|
39
35
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
catch (e) {
|
|
45
|
-
tabId = null;
|
|
46
|
-
context.variables.delete('tabId');
|
|
47
|
-
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
tabId = null;
|
|
38
|
+
context.variables.delete('tabId');
|
|
48
39
|
}
|
|
49
40
|
}
|
|
50
41
|
if (!tabId) {
|
|
@@ -68,24 +59,30 @@ async function getTabId(context) {
|
|
|
68
59
|
}
|
|
69
60
|
return tabId;
|
|
70
61
|
}
|
|
71
|
-
|
|
62
|
+
function getCurrentTabId(windowId) {
|
|
72
63
|
return new Promise((resolve, reject) => {
|
|
73
|
-
chrome.tabs.query({ active: true,
|
|
64
|
+
chrome.tabs.query({ windowId, active: true, lastFocusedWindow: true }, function (tabs) {
|
|
74
65
|
if (chrome.runtime.lastError) {
|
|
75
66
|
console.error('Chrome runtime error:', chrome.runtime.lastError);
|
|
76
67
|
reject(chrome.runtime.lastError);
|
|
77
68
|
return;
|
|
78
69
|
}
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
return;
|
|
70
|
+
if (tabs.length > 0) {
|
|
71
|
+
resolve(tabs[0].id);
|
|
82
72
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
73
|
+
else {
|
|
74
|
+
chrome.tabs.query({ windowId, active: true, currentWindow: true }, function (_tabs) {
|
|
75
|
+
if (_tabs.length > 0) {
|
|
76
|
+
resolve(_tabs[0].id);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
chrome.tabs.query({ windowId, status: 'complete', currentWindow: true }, function (__tabs) {
|
|
81
|
+
resolve(__tabs.length ? __tabs[__tabs.length - 1].id : undefined);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
});
|
|
87
85
|
}
|
|
88
|
-
resolve(tabId);
|
|
89
86
|
});
|
|
90
87
|
});
|
|
91
88
|
}
|
|
@@ -1167,7 +1164,14 @@ class ExportFile {
|
|
|
1167
1164
|
});
|
|
1168
1165
|
}
|
|
1169
1166
|
catch (e) {
|
|
1170
|
-
let tab
|
|
1167
|
+
let tab;
|
|
1168
|
+
const url = 'https://www.google.com';
|
|
1169
|
+
if (context.ekoConfig.workingWindowId) {
|
|
1170
|
+
tab = await open_new_tab(url, false, context.ekoConfig.workingWindowId);
|
|
1171
|
+
}
|
|
1172
|
+
else {
|
|
1173
|
+
tab = await open_new_tab(url, true);
|
|
1174
|
+
}
|
|
1171
1175
|
(_c = (_b = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks) === null || _b === undefined ? undefined : _b.onTabCreated) === null || _c === undefined ? undefined : _c.call(_b, tab.id);
|
|
1172
1176
|
let tabId = tab.id;
|
|
1173
1177
|
await chrome.scripting.executeScript({
|
|
@@ -1680,7 +1684,7 @@ class WebSearch {
|
|
|
1680
1684
|
}
|
|
1681
1685
|
let taskId = new Date().getTime() + '';
|
|
1682
1686
|
let searchs = [{ url: url, keyword: query }];
|
|
1683
|
-
let searchInfo = await deepSearch(context, taskId, searchs, maxResults || 5);
|
|
1687
|
+
let searchInfo = await deepSearch(context, taskId, searchs, maxResults || 5, context.ekoConfig.workingWindowId);
|
|
1684
1688
|
let links = ((_a = searchInfo.result[0]) === null || _a === undefined ? undefined : _a.links) || [];
|
|
1685
1689
|
return links.filter((s) => s.content);
|
|
1686
1690
|
}
|
|
@@ -1753,25 +1757,27 @@ chrome.tabs.onUpdated.addListener(async function (tabId, changeInfo, tab) {
|
|
|
1753
1757
|
* @param {array} searchs search list => [{ url: 'https://bing.com', keyword: 'ai' }]
|
|
1754
1758
|
* @param {number} detailsMaxNum Maximum crawling quantity per search detail page
|
|
1755
1759
|
*/
|
|
1756
|
-
async function deepSearch(context, taskId, searchs, detailsMaxNum,
|
|
1760
|
+
async function deepSearch(context, taskId, searchs, detailsMaxNum, windowId) {
|
|
1757
1761
|
let closeWindow = false;
|
|
1758
|
-
if (!
|
|
1762
|
+
if (!windowId) {
|
|
1759
1763
|
// open new window
|
|
1760
|
-
window = await chrome.windows.create({
|
|
1764
|
+
let window = await chrome.windows.create({
|
|
1761
1765
|
type: 'normal',
|
|
1762
1766
|
state: 'maximized',
|
|
1763
1767
|
url: null,
|
|
1764
1768
|
});
|
|
1769
|
+
windowId = window.id;
|
|
1765
1770
|
closeWindow = true;
|
|
1766
1771
|
}
|
|
1772
|
+
windowId = windowId;
|
|
1767
1773
|
// crawler the search page details page link
|
|
1768
1774
|
// [{ links: [{ title, url }] }]
|
|
1769
|
-
let detailLinkGroups = await doDetailLinkGroups(context, taskId, searchs, detailsMaxNum,
|
|
1775
|
+
let detailLinkGroups = await doDetailLinkGroups(context, taskId, searchs, detailsMaxNum, windowId);
|
|
1770
1776
|
// crawler all details page content and comments
|
|
1771
|
-
let searchInfo = await doPageContent(context, taskId, detailLinkGroups,
|
|
1777
|
+
let searchInfo = await doPageContent(context, taskId, detailLinkGroups, windowId);
|
|
1772
1778
|
console.log('searchInfo: ', searchInfo);
|
|
1773
1779
|
// close window
|
|
1774
|
-
closeWindow && chrome.windows.remove(
|
|
1780
|
+
closeWindow && chrome.windows.remove(windowId);
|
|
1775
1781
|
return searchInfo;
|
|
1776
1782
|
}
|
|
1777
1783
|
/**
|
|
@@ -1783,7 +1789,7 @@ async function deepSearch(context, taskId, searchs, detailsMaxNum, window) {
|
|
|
1783
1789
|
* @param {*} window
|
|
1784
1790
|
* @returns [{ links: [{ title, url }] }]
|
|
1785
1791
|
*/
|
|
1786
|
-
async function doDetailLinkGroups(context, taskId, searchs, detailsMaxNum,
|
|
1792
|
+
async function doDetailLinkGroups(context, taskId, searchs, detailsMaxNum, windowId) {
|
|
1787
1793
|
var _a, _b, _c;
|
|
1788
1794
|
let detailLinkGroups = [];
|
|
1789
1795
|
let countDownLatch = new CountDownLatch(searchs.length);
|
|
@@ -1794,7 +1800,7 @@ async function doDetailLinkGroups(context, taskId, searchs, detailsMaxNum, windo
|
|
|
1794
1800
|
// open new Tab
|
|
1795
1801
|
let tab = await chrome.tabs.create({
|
|
1796
1802
|
url: url,
|
|
1797
|
-
windowId
|
|
1803
|
+
windowId,
|
|
1798
1804
|
});
|
|
1799
1805
|
(_c = (_b = (_a = context.callback) === null || _a === void 0 ? void 0 : _a.hooks) === null || _b === void 0 ? void 0 : _b.onTabCreated) === null || _c === void 0 ? void 0 : _c.call(_b, tab.id);
|
|
1800
1806
|
let eventId = taskId + '_' + i;
|
|
@@ -1847,7 +1853,7 @@ async function doDetailLinkGroups(context, taskId, searchs, detailsMaxNum, windo
|
|
|
1847
1853
|
* @param {*} window
|
|
1848
1854
|
* @returns search info
|
|
1849
1855
|
*/
|
|
1850
|
-
async function doPageContent(context, taskId, detailLinkGroups,
|
|
1856
|
+
async function doPageContent(context, taskId, detailLinkGroups, windowId) {
|
|
1851
1857
|
var _a, _b, _c;
|
|
1852
1858
|
const searchInfo = {
|
|
1853
1859
|
total: 0,
|
|
@@ -1870,7 +1876,7 @@ async function doPageContent(context, taskId, detailLinkGroups, window) {
|
|
|
1870
1876
|
// open new tab
|
|
1871
1877
|
let tab = await chrome.tabs.create({
|
|
1872
1878
|
url: link.url,
|
|
1873
|
-
windowId
|
|
1879
|
+
windowId,
|
|
1874
1880
|
});
|
|
1875
1881
|
(_c = (_b = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks) === null || _b === undefined ? undefined : _b.onTabCreated) === null || _c === undefined ? undefined : _c.call(_b, tab.id);
|
|
1876
1882
|
searchInfo.running++;
|
package/dist/extension.esm.js
CHANGED
|
@@ -28,21 +28,12 @@ async function getWindowId(context) {
|
|
|
28
28
|
async function getTabId(context) {
|
|
29
29
|
let tabId = context.variables.get('tabId');
|
|
30
30
|
if (tabId) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// Check if it's a valid integer
|
|
34
|
-
if (!Number.isInteger(tabId)) {
|
|
35
|
-
context.variables.delete('tabId');
|
|
36
|
-
tabId = null;
|
|
31
|
+
try {
|
|
32
|
+
await chrome.tabs.get(tabId);
|
|
37
33
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
catch (e) {
|
|
43
|
-
tabId = null;
|
|
44
|
-
context.variables.delete('tabId');
|
|
45
|
-
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
tabId = null;
|
|
36
|
+
context.variables.delete('tabId');
|
|
46
37
|
}
|
|
47
38
|
}
|
|
48
39
|
if (!tabId) {
|
|
@@ -66,24 +57,30 @@ async function getTabId(context) {
|
|
|
66
57
|
}
|
|
67
58
|
return tabId;
|
|
68
59
|
}
|
|
69
|
-
|
|
60
|
+
function getCurrentTabId(windowId) {
|
|
70
61
|
return new Promise((resolve, reject) => {
|
|
71
|
-
chrome.tabs.query({ active: true,
|
|
62
|
+
chrome.tabs.query({ windowId, active: true, lastFocusedWindow: true }, function (tabs) {
|
|
72
63
|
if (chrome.runtime.lastError) {
|
|
73
64
|
console.error('Chrome runtime error:', chrome.runtime.lastError);
|
|
74
65
|
reject(chrome.runtime.lastError);
|
|
75
66
|
return;
|
|
76
67
|
}
|
|
77
|
-
if (
|
|
78
|
-
|
|
79
|
-
return;
|
|
68
|
+
if (tabs.length > 0) {
|
|
69
|
+
resolve(tabs[0].id);
|
|
80
70
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
71
|
+
else {
|
|
72
|
+
chrome.tabs.query({ windowId, active: true, currentWindow: true }, function (_tabs) {
|
|
73
|
+
if (_tabs.length > 0) {
|
|
74
|
+
resolve(_tabs[0].id);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
chrome.tabs.query({ windowId, status: 'complete', currentWindow: true }, function (__tabs) {
|
|
79
|
+
resolve(__tabs.length ? __tabs[__tabs.length - 1].id : undefined);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
});
|
|
85
83
|
}
|
|
86
|
-
resolve(tabId);
|
|
87
84
|
});
|
|
88
85
|
});
|
|
89
86
|
}
|
|
@@ -1165,7 +1162,14 @@ class ExportFile {
|
|
|
1165
1162
|
});
|
|
1166
1163
|
}
|
|
1167
1164
|
catch (e) {
|
|
1168
|
-
let tab
|
|
1165
|
+
let tab;
|
|
1166
|
+
const url = 'https://www.google.com';
|
|
1167
|
+
if (context.ekoConfig.workingWindowId) {
|
|
1168
|
+
tab = await open_new_tab(url, false, context.ekoConfig.workingWindowId);
|
|
1169
|
+
}
|
|
1170
|
+
else {
|
|
1171
|
+
tab = await open_new_tab(url, true);
|
|
1172
|
+
}
|
|
1169
1173
|
(_c = (_b = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks) === null || _b === undefined ? undefined : _b.onTabCreated) === null || _c === undefined ? undefined : _c.call(_b, tab.id);
|
|
1170
1174
|
let tabId = tab.id;
|
|
1171
1175
|
await chrome.scripting.executeScript({
|
|
@@ -1678,7 +1682,7 @@ class WebSearch {
|
|
|
1678
1682
|
}
|
|
1679
1683
|
let taskId = new Date().getTime() + '';
|
|
1680
1684
|
let searchs = [{ url: url, keyword: query }];
|
|
1681
|
-
let searchInfo = await deepSearch(context, taskId, searchs, maxResults || 5);
|
|
1685
|
+
let searchInfo = await deepSearch(context, taskId, searchs, maxResults || 5, context.ekoConfig.workingWindowId);
|
|
1682
1686
|
let links = ((_a = searchInfo.result[0]) === null || _a === undefined ? undefined : _a.links) || [];
|
|
1683
1687
|
return links.filter((s) => s.content);
|
|
1684
1688
|
}
|
|
@@ -1751,25 +1755,27 @@ chrome.tabs.onUpdated.addListener(async function (tabId, changeInfo, tab) {
|
|
|
1751
1755
|
* @param {array} searchs search list => [{ url: 'https://bing.com', keyword: 'ai' }]
|
|
1752
1756
|
* @param {number} detailsMaxNum Maximum crawling quantity per search detail page
|
|
1753
1757
|
*/
|
|
1754
|
-
async function deepSearch(context, taskId, searchs, detailsMaxNum,
|
|
1758
|
+
async function deepSearch(context, taskId, searchs, detailsMaxNum, windowId) {
|
|
1755
1759
|
let closeWindow = false;
|
|
1756
|
-
if (!
|
|
1760
|
+
if (!windowId) {
|
|
1757
1761
|
// open new window
|
|
1758
|
-
window = await chrome.windows.create({
|
|
1762
|
+
let window = await chrome.windows.create({
|
|
1759
1763
|
type: 'normal',
|
|
1760
1764
|
state: 'maximized',
|
|
1761
1765
|
url: null,
|
|
1762
1766
|
});
|
|
1767
|
+
windowId = window.id;
|
|
1763
1768
|
closeWindow = true;
|
|
1764
1769
|
}
|
|
1770
|
+
windowId = windowId;
|
|
1765
1771
|
// crawler the search page details page link
|
|
1766
1772
|
// [{ links: [{ title, url }] }]
|
|
1767
|
-
let detailLinkGroups = await doDetailLinkGroups(context, taskId, searchs, detailsMaxNum,
|
|
1773
|
+
let detailLinkGroups = await doDetailLinkGroups(context, taskId, searchs, detailsMaxNum, windowId);
|
|
1768
1774
|
// crawler all details page content and comments
|
|
1769
|
-
let searchInfo = await doPageContent(context, taskId, detailLinkGroups,
|
|
1775
|
+
let searchInfo = await doPageContent(context, taskId, detailLinkGroups, windowId);
|
|
1770
1776
|
console.log('searchInfo: ', searchInfo);
|
|
1771
1777
|
// close window
|
|
1772
|
-
closeWindow && chrome.windows.remove(
|
|
1778
|
+
closeWindow && chrome.windows.remove(windowId);
|
|
1773
1779
|
return searchInfo;
|
|
1774
1780
|
}
|
|
1775
1781
|
/**
|
|
@@ -1781,7 +1787,7 @@ async function deepSearch(context, taskId, searchs, detailsMaxNum, window) {
|
|
|
1781
1787
|
* @param {*} window
|
|
1782
1788
|
* @returns [{ links: [{ title, url }] }]
|
|
1783
1789
|
*/
|
|
1784
|
-
async function doDetailLinkGroups(context, taskId, searchs, detailsMaxNum,
|
|
1790
|
+
async function doDetailLinkGroups(context, taskId, searchs, detailsMaxNum, windowId) {
|
|
1785
1791
|
var _a, _b, _c;
|
|
1786
1792
|
let detailLinkGroups = [];
|
|
1787
1793
|
let countDownLatch = new CountDownLatch(searchs.length);
|
|
@@ -1792,7 +1798,7 @@ async function doDetailLinkGroups(context, taskId, searchs, detailsMaxNum, windo
|
|
|
1792
1798
|
// open new Tab
|
|
1793
1799
|
let tab = await chrome.tabs.create({
|
|
1794
1800
|
url: url,
|
|
1795
|
-
windowId
|
|
1801
|
+
windowId,
|
|
1796
1802
|
});
|
|
1797
1803
|
(_c = (_b = (_a = context.callback) === null || _a === void 0 ? void 0 : _a.hooks) === null || _b === void 0 ? void 0 : _b.onTabCreated) === null || _c === void 0 ? void 0 : _c.call(_b, tab.id);
|
|
1798
1804
|
let eventId = taskId + '_' + i;
|
|
@@ -1845,7 +1851,7 @@ async function doDetailLinkGroups(context, taskId, searchs, detailsMaxNum, windo
|
|
|
1845
1851
|
* @param {*} window
|
|
1846
1852
|
* @returns search info
|
|
1847
1853
|
*/
|
|
1848
|
-
async function doPageContent(context, taskId, detailLinkGroups,
|
|
1854
|
+
async function doPageContent(context, taskId, detailLinkGroups, windowId) {
|
|
1849
1855
|
var _a, _b, _c;
|
|
1850
1856
|
const searchInfo = {
|
|
1851
1857
|
total: 0,
|
|
@@ -1868,7 +1874,7 @@ async function doPageContent(context, taskId, detailLinkGroups, window) {
|
|
|
1868
1874
|
// open new tab
|
|
1869
1875
|
let tab = await chrome.tabs.create({
|
|
1870
1876
|
url: link.url,
|
|
1871
|
-
windowId
|
|
1877
|
+
windowId,
|
|
1872
1878
|
});
|
|
1873
1879
|
(_c = (_b = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks) === null || _b === undefined ? undefined : _b.onTabCreated) === null || _c === undefined ? undefined : _c.call(_b, tab.id);
|
|
1874
1880
|
searchInfo.running++;
|
|
@@ -118,23 +118,41 @@ function type(request) {
|
|
|
118
118
|
return false;
|
|
119
119
|
}
|
|
120
120
|
let input;
|
|
121
|
-
if (element.tagName == '
|
|
121
|
+
if (element.tagName == 'IFRAME') {
|
|
122
|
+
let iframeDoc = element.contentDocument || element.contentWindow.document;
|
|
123
|
+
input =
|
|
124
|
+
iframeDoc.querySelector('textarea') ||
|
|
125
|
+
iframeDoc.querySelector('*[contenteditable="true"]') ||
|
|
126
|
+
iframeDoc.querySelector('input');
|
|
127
|
+
}
|
|
128
|
+
else if (element.tagName == 'INPUT' ||
|
|
122
129
|
element.tagName == 'TEXTAREA' ||
|
|
123
130
|
element.childElementCount == 0) {
|
|
124
131
|
input = element;
|
|
125
132
|
}
|
|
126
133
|
else {
|
|
127
|
-
input =
|
|
134
|
+
input =
|
|
135
|
+
element.querySelector('input') ||
|
|
136
|
+
element.querySelector('textarea') ||
|
|
137
|
+
element.querySelector('*[contenteditable="true"]') ||
|
|
138
|
+
element;
|
|
128
139
|
}
|
|
129
140
|
input.focus && input.focus();
|
|
130
141
|
if (!text) {
|
|
131
|
-
if (input.value ==
|
|
132
|
-
|
|
142
|
+
if (input.value == undefined) {
|
|
143
|
+
input.textContent = '';
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
input.value = '';
|
|
133
147
|
}
|
|
134
|
-
input.value = '';
|
|
135
148
|
}
|
|
136
149
|
else {
|
|
137
|
-
input.value
|
|
150
|
+
if (input.value == undefined) {
|
|
151
|
+
input.textContent += text;
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
input.value += text;
|
|
155
|
+
}
|
|
138
156
|
}
|
|
139
157
|
let result = input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
140
158
|
if (enter) {
|