@ejazullah/browser-mcp 0.0.56 → 0.0.57
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/cli.js +1 -18
- package/index.js +1 -1060
- package/lib/auth.js +1 -82
- package/lib/browserContextFactory.js +1 -205
- package/lib/browserServerBackend.js +1 -125
- package/lib/config.js +1 -266
- package/lib/context.js +1 -232
- package/lib/databaseLogger.js +1 -264
- package/lib/extension/cdpRelay.js +1 -346
- package/lib/extension/extensionContextFactory.js +1 -56
- package/lib/extension/main.js +1 -26
- package/lib/fileUtils.js +1 -32
- package/lib/httpServer.js +1 -39
- package/lib/index.js +1 -39
- package/lib/javascript.js +1 -49
- package/lib/log.js +1 -21
- package/lib/loop/loop.js +1 -69
- package/lib/loop/loopClaude.js +1 -152
- package/lib/loop/loopOpenAI.js +1 -143
- package/lib/loop/main.js +1 -60
- package/lib/loopTools/context.js +1 -66
- package/lib/loopTools/main.js +1 -49
- package/lib/loopTools/perform.js +1 -32
- package/lib/loopTools/snapshot.js +1 -29
- package/lib/loopTools/tool.js +1 -18
- package/lib/manualPromise.js +1 -111
- package/lib/mcp/inProcessTransport.js +1 -72
- package/lib/mcp/server.js +1 -93
- package/lib/mcp/transport.js +1 -217
- package/lib/mongoDBLogger.js +1 -252
- package/lib/package.js +1 -20
- package/lib/program.js +1 -113
- package/lib/response.js +1 -172
- package/lib/sessionLog.js +1 -156
- package/lib/tab.js +1 -266
- package/lib/tools/cdp.js +1 -169
- package/lib/tools/common.js +1 -55
- package/lib/tools/console.js +1 -33
- package/lib/tools/dialogs.js +1 -47
- package/lib/tools/evaluate.js +1 -53
- package/lib/tools/extraction.js +1 -217
- package/lib/tools/files.js +1 -44
- package/lib/tools/forms.js +1 -180
- package/lib/tools/getext.js +1 -99
- package/lib/tools/install.js +1 -53
- package/lib/tools/interactions.js +1 -191
- package/lib/tools/keyboard.js +1 -86
- package/lib/tools/mouse.js +1 -99
- package/lib/tools/navigate.js +1 -70
- package/lib/tools/network.js +1 -41
- package/lib/tools/pdf.js +1 -40
- package/lib/tools/screenshot.js +1 -75
- package/lib/tools/selectors.js +1 -233
- package/lib/tools/snapshot.js +1 -169
- package/lib/tools/states.js +1 -147
- package/lib/tools/tabs.js +1 -87
- package/lib/tools/tool.js +1 -33
- package/lib/tools/utils.js +1 -74
- package/lib/tools/wait.js +1 -56
- package/lib/tools.js +1 -64
- package/lib/utils.js +1 -26
- package/package.json +5 -2
package/lib/tools/forms.js
CHANGED
|
@@ -1,180 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Microsoft Corporation.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { z } from 'zod';
|
|
17
|
-
import { defineTabTool } from './tool.js';
|
|
18
|
-
import { elementSchema } from './snapshot.js';
|
|
19
|
-
import { generateLocator } from './utils.js';
|
|
20
|
-
// Schema for CSS selector operations
|
|
21
|
-
const selectorSchema = z.object({
|
|
22
|
-
selector: z.string().describe('CSS selector to target the element'),
|
|
23
|
-
index: z.number().optional().describe('Index of element if multiple elements match (0-based)'),
|
|
24
|
-
});
|
|
25
|
-
// Check/uncheck checkbox
|
|
26
|
-
const checkCheckbox = defineTabTool({
|
|
27
|
-
capability: 'core',
|
|
28
|
-
schema: {
|
|
29
|
-
name: 'browser_check_checkbox',
|
|
30
|
-
title: 'Check or uncheck checkbox',
|
|
31
|
-
description: 'Check or uncheck a checkbox element',
|
|
32
|
-
inputSchema: elementSchema.extend({
|
|
33
|
-
checked: z.boolean().describe('Whether to check (true) or uncheck (false) the checkbox'),
|
|
34
|
-
}),
|
|
35
|
-
type: 'destructive',
|
|
36
|
-
},
|
|
37
|
-
handle: async (tab, params, response) => {
|
|
38
|
-
try {
|
|
39
|
-
// Get locator with selector information for database logging
|
|
40
|
-
const { locator, selector, resolvedSelector } = await tab.refLocatorWithSelector(params);
|
|
41
|
-
// Store element interaction data for database logging
|
|
42
|
-
response.setElementInteraction({
|
|
43
|
-
elementRef: params.ref,
|
|
44
|
-
elementDescription: params.element,
|
|
45
|
-
playwrightSelector: selector,
|
|
46
|
-
resolvedSelector: resolvedSelector,
|
|
47
|
-
});
|
|
48
|
-
if (params.checked) {
|
|
49
|
-
await locator.check();
|
|
50
|
-
response.addCode(`await page.${await generateLocator(locator)}.check();`);
|
|
51
|
-
response.addResult('Checkbox checked successfully');
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
await locator.uncheck();
|
|
55
|
-
response.addCode(`await page.${await generateLocator(locator)}.uncheck();`);
|
|
56
|
-
response.addResult('Checkbox unchecked successfully');
|
|
57
|
-
}
|
|
58
|
-
response.setIncludeSnapshot();
|
|
59
|
-
}
|
|
60
|
-
catch (error) {
|
|
61
|
-
response.addError(`Failed to ${params.checked ? 'check' : 'uncheck'} checkbox: ${error}`);
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
// Select radio button
|
|
66
|
-
const selectRadio = defineTabTool({
|
|
67
|
-
capability: 'core',
|
|
68
|
-
schema: {
|
|
69
|
-
name: 'browser_select_radio',
|
|
70
|
-
title: 'Select radio button',
|
|
71
|
-
description: 'Select a radio button',
|
|
72
|
-
inputSchema: elementSchema,
|
|
73
|
-
type: 'destructive',
|
|
74
|
-
},
|
|
75
|
-
handle: async (tab, params, response) => {
|
|
76
|
-
try {
|
|
77
|
-
// Get locator with selector information for database logging
|
|
78
|
-
const { locator, selector, resolvedSelector } = await tab.refLocatorWithSelector(params);
|
|
79
|
-
// Store element interaction data for database logging
|
|
80
|
-
response.setElementInteraction({
|
|
81
|
-
elementRef: params.ref,
|
|
82
|
-
elementDescription: params.element,
|
|
83
|
-
playwrightSelector: selector,
|
|
84
|
-
resolvedSelector: resolvedSelector,
|
|
85
|
-
});
|
|
86
|
-
await locator.check();
|
|
87
|
-
response.addCode(`await page.${await generateLocator(locator)}.check();`);
|
|
88
|
-
response.addResult('Radio button selected successfully');
|
|
89
|
-
response.setIncludeSnapshot();
|
|
90
|
-
}
|
|
91
|
-
catch (error) {
|
|
92
|
-
response.addError(`Failed to select radio button: ${error}`);
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
});
|
|
96
|
-
// Clear input field
|
|
97
|
-
const clearInput = defineTabTool({
|
|
98
|
-
capability: 'core',
|
|
99
|
-
schema: {
|
|
100
|
-
name: 'browser_clear_input',
|
|
101
|
-
title: 'Clear input field',
|
|
102
|
-
description: 'Clear the content of an input field',
|
|
103
|
-
inputSchema: elementSchema,
|
|
104
|
-
type: 'destructive',
|
|
105
|
-
},
|
|
106
|
-
handle: async (tab, params, response) => {
|
|
107
|
-
try {
|
|
108
|
-
// Get locator with selector information for database logging
|
|
109
|
-
const { locator, selector, resolvedSelector } = await tab.refLocatorWithSelector(params);
|
|
110
|
-
// Store element interaction data for database logging
|
|
111
|
-
response.setElementInteraction({
|
|
112
|
-
elementRef: params.ref,
|
|
113
|
-
elementDescription: params.element,
|
|
114
|
-
playwrightSelector: selector,
|
|
115
|
-
resolvedSelector: resolvedSelector,
|
|
116
|
-
});
|
|
117
|
-
await locator.clear();
|
|
118
|
-
response.addCode(`await page.${await generateLocator(locator)}.clear();`);
|
|
119
|
-
response.addResult('Input field cleared successfully');
|
|
120
|
-
response.setIncludeSnapshot();
|
|
121
|
-
}
|
|
122
|
-
catch (error) {
|
|
123
|
-
response.addError(`Failed to clear input field: ${error}`);
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
});
|
|
127
|
-
// Get input value
|
|
128
|
-
const getInputValue = defineTabTool({
|
|
129
|
-
capability: 'core',
|
|
130
|
-
schema: {
|
|
131
|
-
name: 'browser_get_input_value',
|
|
132
|
-
title: 'Get input field value',
|
|
133
|
-
description: 'Get the current value of an input field',
|
|
134
|
-
inputSchema: elementSchema,
|
|
135
|
-
type: 'readOnly',
|
|
136
|
-
},
|
|
137
|
-
handle: async (tab, params, response) => {
|
|
138
|
-
try {
|
|
139
|
-
const locator = await tab.refLocator(params);
|
|
140
|
-
const value = await locator.inputValue();
|
|
141
|
-
response.addCode(`const value = await page.${await generateLocator(locator)}.inputValue();`);
|
|
142
|
-
response.addResult(`Input value: ${value}`);
|
|
143
|
-
}
|
|
144
|
-
catch (error) {
|
|
145
|
-
response.addError(`Failed to get input value: ${error}`);
|
|
146
|
-
}
|
|
147
|
-
},
|
|
148
|
-
});
|
|
149
|
-
// Submit form
|
|
150
|
-
const submitForm = defineTabTool({
|
|
151
|
-
capability: 'core',
|
|
152
|
-
schema: {
|
|
153
|
-
name: 'browser_submit_form',
|
|
154
|
-
title: 'Submit form',
|
|
155
|
-
description: 'Submit a form element',
|
|
156
|
-
inputSchema: elementSchema,
|
|
157
|
-
type: 'destructive',
|
|
158
|
-
},
|
|
159
|
-
handle: async (tab, params, response) => {
|
|
160
|
-
try {
|
|
161
|
-
const locator = await tab.refLocator(params);
|
|
162
|
-
await tab.waitForCompletion(async () => {
|
|
163
|
-
await locator.evaluate((form) => form.submit());
|
|
164
|
-
});
|
|
165
|
-
response.addCode(`await page.${await generateLocator(locator)}.evaluate(form => form.submit());`);
|
|
166
|
-
response.addResult('Form submitted successfully');
|
|
167
|
-
response.setIncludeSnapshot();
|
|
168
|
-
}
|
|
169
|
-
catch (error) {
|
|
170
|
-
response.addError(`Failed to submit form: ${error}`);
|
|
171
|
-
}
|
|
172
|
-
},
|
|
173
|
-
});
|
|
174
|
-
export default [
|
|
175
|
-
checkCheckbox,
|
|
176
|
-
selectRadio,
|
|
177
|
-
clearInput,
|
|
178
|
-
getInputValue,
|
|
179
|
-
submitForm,
|
|
180
|
-
];
|
|
1
|
+
const _0x2eee9c=_0xbb6a;(function(_0x26ddfc,_0x1afa5c){const _0x355dce=_0xbb6a,_0x327efc=_0x26ddfc();while(!![]){try{const _0x24cb8c=parseInt(_0x355dce(0xfe))/0x1+parseInt(_0x355dce(0xcb))/0x2+-parseInt(_0x355dce(0xc9))/0x3+-parseInt(_0x355dce(0xda))/0x4*(parseInt(_0x355dce(0xaf))/0x5)+parseInt(_0x355dce(0xb8))/0x6*(parseInt(_0x355dce(0xdd))/0x7)+parseInt(_0x355dce(0xb2))/0x8*(-parseInt(_0x355dce(0xba))/0x9)+parseInt(_0x355dce(0xfd))/0xa*(-parseInt(_0x355dce(0x105))/0xb);if(_0x24cb8c===_0x1afa5c)break;else _0x327efc['push'](_0x327efc['shift']());}catch(_0x4e09bf){_0x327efc['push'](_0x327efc['shift']());}}}(_0x1c69,0x2a988));const _0x5f32ba=(function(){let _0x51461b=!![];return function(_0x29d78d,_0x40e972){const _0x19061a=_0x51461b?function(){if(_0x40e972){const _0x30cf31=_0x40e972['apply'](_0x29d78d,arguments);return _0x40e972=null,_0x30cf31;}}:function(){};return _0x51461b=![],_0x19061a;};}()),_0x53ca11=_0x5f32ba(this,function(){const _0x51452d=_0xbb6a,_0x24c4cc={};_0x24c4cc[_0x51452d(0xc0)]=_0x51452d(0x102);const _0x5c7225=_0x24c4cc;return _0x53ca11[_0x51452d(0xea)]()[_0x51452d(0xde)](_0x5c7225[_0x51452d(0xc0)])[_0x51452d(0xea)]()[_0x51452d(0xb1)](_0x53ca11)[_0x51452d(0xde)](_0x5c7225[_0x51452d(0xc0)]);});_0x53ca11();import{z}from'zod';function _0xbb6a(_0x501da5,_0x22d643){_0x501da5=_0x501da5-0xac;const _0x12f99d=_0x1c69();let _0x53ca11=_0x12f99d[_0x501da5];if(_0xbb6a['PBhPCo']===undefined){var _0x5f32ba=function(_0x17606a){const _0x33465e='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x2b5def='',_0x734624='',_0xbadc50=_0x2b5def+_0x5f32ba;for(let _0x3acacc=0x0,_0x33ec16,_0x3d2638,_0x5cdc33=0x0;_0x3d2638=_0x17606a['charAt'](_0x5cdc33++);~_0x3d2638&&(_0x33ec16=_0x3acacc%0x4?_0x33ec16*0x40+_0x3d2638:_0x3d2638,_0x3acacc++%0x4)?_0x2b5def+=_0xbadc50['charCodeAt'](_0x5cdc33+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0x33ec16>>(-0x2*_0x3acacc&0x6)):_0x3acacc:0x0){_0x3d2638=_0x33465e['indexOf'](_0x3d2638);}for(let _0x54aa79=0x0,_0x1fd060=_0x2b5def['length'];_0x54aa79<_0x1fd060;_0x54aa79++){_0x734624+='%'+('00'+_0x2b5def['charCodeAt'](_0x54aa79)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x734624);};_0xbb6a['lgLzaC']=_0x5f32ba,_0xbb6a['mIsrbz']={},_0xbb6a['PBhPCo']=!![];}const _0x1c6984=_0x12f99d[0x0],_0xbb6a2c=_0x501da5+_0x1c6984,_0x31bc3a=_0xbb6a['mIsrbz'][_0xbb6a2c];if(!_0x31bc3a){const _0x4fe01f=function(_0x2cf968){this['bphQmF']=_0x2cf968,this['EnbsEO']=[0x1,0x0,0x0],this['wFNGIG']=function(){return'newState';},this['nQDBQK']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['ZpxanN']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x4fe01f['prototype']['AXRIQQ']=function(){const _0x163062=new RegExp(this['nQDBQK']+this['ZpxanN']),_0x3d911f=_0x163062['test'](this['wFNGIG']['toString']())?--this['EnbsEO'][0x1]:--this['EnbsEO'][0x0];return this['cxWaBy'](_0x3d911f);},_0x4fe01f['prototype']['cxWaBy']=function(_0x157fbf){if(!Boolean(~_0x157fbf))return _0x157fbf;return this['cSiqPE'](this['bphQmF']);},_0x4fe01f['prototype']['cSiqPE']=function(_0x205e09){for(let _0x3f8551=0x0,_0x44c4b6=this['EnbsEO']['length'];_0x3f8551<_0x44c4b6;_0x3f8551++){this['EnbsEO']['push'](Math['round'](Math['random']())),_0x44c4b6=this['EnbsEO']['length'];}return _0x205e09(this['EnbsEO'][0x0]);},new _0x4fe01f(_0xbb6a)['AXRIQQ'](),_0x53ca11=_0xbb6a['lgLzaC'](_0x53ca11),_0xbb6a['mIsrbz'][_0xbb6a2c]=_0x53ca11;}else _0x53ca11=_0x31bc3a;return _0x53ca11;}import{defineTabTool}from'./tool.js';import{elementSchema}from'./snapshot.js';import{generateLocator}from'./utils.js';const selectorSchema=z['object']({'selector':z[_0x2eee9c(0xf7)]()[_0x2eee9c(0xae)](_0x2eee9c(0xc5)),'index':z[_0x2eee9c(0xfb)]()[_0x2eee9c(0x10b)]()[_0x2eee9c(0xae)](_0x2eee9c(0xe2))}),checkCheckbox=defineTabTool({'capability':_0x2eee9c(0xbe),'schema':{'name':_0x2eee9c(0xf9),'title':_0x2eee9c(0xf1),'description':_0x2eee9c(0xd6),'inputSchema':elementSchema[_0x2eee9c(0xbf)]({'checked':z[_0x2eee9c(0xfa)]()[_0x2eee9c(0xae)](_0x2eee9c(0x108))}),'type':_0x2eee9c(0xb7)},'handle':async(_0x24262b,_0x303f44,_0x4aac6a)=>{const _0x45e75e=_0x2eee9c,_0x27500a={'IzoGY':function(_0x3d9a19,_0x4a0efe){return _0x3d9a19(_0x4a0efe);},'hifhg':_0x45e75e(0x109),'JpFcj':function(_0x2bb619,_0x54096a){return _0x2bb619(_0x54096a);},'xuJGs':_0x45e75e(0xf3),'CuUXo':_0x45e75e(0xe4),'PKaAy':_0x45e75e(0xcc)};try{const {locator:_0x2f1edd,selector:_0x2c040b,resolvedSelector:_0x5b8dbd}=await _0x24262b[_0x45e75e(0xd0)](_0x303f44),_0x3999f8={};_0x3999f8[_0x45e75e(0xb0)]=_0x303f44[_0x45e75e(0xe5)],_0x3999f8[_0x45e75e(0xc1)]=_0x303f44[_0x45e75e(0xad)],_0x3999f8[_0x45e75e(0xe7)]=_0x2c040b,_0x3999f8[_0x45e75e(0xce)]=_0x5b8dbd,_0x4aac6a[_0x45e75e(0xdc)](_0x3999f8),_0x303f44[_0x45e75e(0xe9)]?(await _0x2f1edd[_0x45e75e(0xe4)](),_0x4aac6a[_0x45e75e(0xe3)](_0x45e75e(0xd7)+await _0x27500a[_0x45e75e(0xbd)](generateLocator,_0x2f1edd)+_0x45e75e(0x100)),_0x4aac6a[_0x45e75e(0x106)](_0x27500a[_0x45e75e(0xd4)])):(await _0x2f1edd[_0x45e75e(0xcc)](),_0x4aac6a[_0x45e75e(0xe3)](_0x45e75e(0xd7)+await _0x27500a[_0x45e75e(0xff)](generateLocator,_0x2f1edd)+_0x45e75e(0xac)),_0x4aac6a[_0x45e75e(0x106)](_0x27500a[_0x45e75e(0xf0)])),_0x4aac6a[_0x45e75e(0xd2)]();}catch(_0x43a6c9){_0x4aac6a[_0x45e75e(0xd1)](_0x45e75e(0x10a)+(_0x303f44[_0x45e75e(0xe9)]?_0x27500a[_0x45e75e(0xb3)]:_0x27500a[_0x45e75e(0xc8)])+_0x45e75e(0xd9)+_0x43a6c9);}}}),_0x2ac6a2={};_0x2ac6a2[_0x2eee9c(0xdb)]=_0x2eee9c(0xed),_0x2ac6a2[_0x2eee9c(0xbc)]=_0x2eee9c(0xb9),_0x2ac6a2[_0x2eee9c(0x103)]=_0x2eee9c(0xeb),_0x2ac6a2[_0x2eee9c(0xf6)]=elementSchema,_0x2ac6a2[_0x2eee9c(0xe8)]=_0x2eee9c(0xb7);const selectRadio=defineTabTool({'capability':'core','schema':_0x2ac6a2,'handle':async(_0x19dfc5,_0x149772,_0x23e335)=>{const _0x473ff1=_0x2eee9c,_0x53b8ef={'soAhf':function(_0x196cf1,_0x3c2e17){return _0x196cf1(_0x3c2e17);},'bmdVK':_0x473ff1(0xc4)};try{const {locator:_0x333e05,selector:_0x51ff5c,resolvedSelector:_0x2260dc}=await _0x19dfc5[_0x473ff1(0xd0)](_0x149772),_0x108043={};_0x108043['elementRef']=_0x149772[_0x473ff1(0xe5)],_0x108043[_0x473ff1(0xc1)]=_0x149772[_0x473ff1(0xad)],_0x108043[_0x473ff1(0xe7)]=_0x51ff5c,_0x108043[_0x473ff1(0xce)]=_0x2260dc,_0x23e335[_0x473ff1(0xdc)](_0x108043),await _0x333e05[_0x473ff1(0xe4)](),_0x23e335[_0x473ff1(0xe3)](_0x473ff1(0xd7)+await _0x53b8ef[_0x473ff1(0xd8)](generateLocator,_0x333e05)+_0x473ff1(0x100)),_0x23e335[_0x473ff1(0x106)](_0x53b8ef[_0x473ff1(0x101)]),_0x23e335[_0x473ff1(0xd2)]();}catch(_0x14dc24){_0x23e335['addError'](_0x473ff1(0xe1)+_0x14dc24);}}}),_0x3b0022={};_0x3b0022[_0x2eee9c(0xdb)]=_0x2eee9c(0xf2),_0x3b0022[_0x2eee9c(0xbc)]=_0x2eee9c(0xd3),_0x3b0022[_0x2eee9c(0x103)]=_0x2eee9c(0xc3),_0x3b0022[_0x2eee9c(0xf6)]=elementSchema,_0x3b0022[_0x2eee9c(0xe8)]=_0x2eee9c(0xb7);function _0x1c69(){const _0x1faacd=['C2vHCMnO','CMvMtg9JyxrVCG','tvLcAgG','rMfPBgvKihrVihnLBgvJDcbYywrPBYbIDxr0B246ia','sw5KzxGGB2yGzwXLBwvUDcbPzIbTDwX0AxbSzsbLBgvTzw50CYbTyxrJAcaOmc1IyxnLzcK','ywrKq29Kzq','y2HLy2S','CMvM','lMv2ywX1yxrLkgzVCM0Gpt4GzM9YBs5ZDwjTAxqOksK7','CgXHExDYAwDODfnLBgvJDg9Y','DhLWzq','y2HLy2TLza','Dg9tDhjPBMC','u2vSzwn0igeGCMfKAw8GyNv0Dg9U','rMfPBgvKihrVigDLDcbPBNb1Dcb2ywX1ztOG','yNjVD3nLCL9ZzwXLy3rFCMfKAw8','r2v0igLUChv0igzPzwXKihzHBhvL','C3vIBwL0','Ehvkr3m','q2HLy2SGB3iGDw5JAgvJAYbJAgvJA2jVEa','yNjVD3nLCL9JBgvHCL9PBNb1Da','q2HLy2TIB3GGDw5JAgvJA2vKihn1y2nLC3nMDwXSEq','rMfPBgvKihrVignSzwfYigLUChv0igzPzwXKoIa','D2fPDezVCKnVBxbSzxrPB24','Aw5WDxrty2HLBwe','C3rYAw5N','y2XLyxi','yNjVD3nLCL9JAgvJA19JAgvJA2jVEa','yM9VBgvHBG','BNvTyMvY','lMnSzwfYkcK7','mtbLDM5uDuq','mJKYmJq0swfcvwj2','sNbgy2O','lMnOzwnRkcK7','yM1KvKS','kcGOlISPkYKRksSK','zgvZy3jPChrPB24','u3vIBwL0igeGzM9YBsbLBgvTzw50','mJuZnJq5t1jKzuPs','ywrKuMvZDwX0','rMfPBgvKihrVihn1yM1PDcbMB3jToIa','v2HLDgHLCIb0BYbJAgvJAYaODhj1zsKGB3iGDw5JAgvJAYaOzMfSC2uPihrOzsbJAgvJA2jVEa','q2HLy2TIB3GGy2HLy2TLzcbZDwnJzxnZzNvSBhK','rMfPBgvKihrVia','B3b0Aw9UywW','lNvUy2HLy2SOktS','zwXLBwvUDa','zgvZy3jPyMu','mZq1yujYsMHp','zwXLBwvUDfjLzG','y29UC3rYDwn0B3i','mZi4q2PWD3Hn','q3vvwg8','u3vIBwL0igzVCM0','rM9YBsbZDwjTAxr0zwqGC3vJy2vZC2z1BgX5','r2v0ihrOzsbJDxjYzw50ihzHBhvLig9MigfUigLUChv0igzPzwXK','zgvZDhj1y3rPDMu','nJmWmdqYwLr3zg5g','u2vSzwn0ihjHzgLVigj1DhrVBG','nty5n2zwAePQCG','lMLUChv0vMfSDwuOktS','DgL0Bgu','sxPVr1K','y29Yzq','zxH0zw5K','zuDbzM8','zwXLBwvUDerLC2nYAxb0Aw9U','CMvHze9UBhK','q2XLyxiGDgHLignVBNrLBNqGB2yGyw4GAw5WDxqGzMLLBgq','uMfKAw8GyNv0Dg9UihnLBgvJDgvKihn1y2nLC3nMDwXSEq','q1ntihnLBgvJDg9YihrVihrHCMDLDcb0AguGzwXLBwvUDa','zxzHBhvHDgu','sw5WDxqGzMLLBgqGy2XLyxjLzcbZDwnJzxnZzNvSBhK','ueTHqxK','ntyYmZiZEM1HzMji','yNjVD3nLCL9ZDwjTAxrFzM9YBq','mtG4ndm4DxDywenq','Dw5JAgvJAW','sw5WDxqGDMfSDwu6ia','CMvZB2X2zwrtzwXLy3rVCG','yNjVD3nLCL9NzxrFAw5WDxrFDMfSDwu','CMvMtg9JyxrVCLDPDgHtzwXLy3rVCG','ywrKrxjYB3i','C2v0sw5JBhvKzvnUyxbZAg90','q2XLyxiGAw5WDxqGzMLLBgq','AgLMAgC','y29UC3qGDMfSDwuGpsbHD2fPDcbWywDLlG','q2HLy2SGB3iGDw5JAgvJAYbHignOzwnRyM94igvSzw1LBNq','yxDHAxqGCgfNzs4','C29bAgy','ignOzwnRyM94oIa','mty4ndrcqLz1C1q','BMfTzq','C2v0rwXLBwvUDeLUDgvYywn0Aw9U','mJfZzKDYuwW'];_0x1c69=function(){return _0x1faacd;};return _0x1c69();}const clearInput=defineTabTool({'capability':_0x2eee9c(0xbe),'schema':_0x3b0022,'handle':async(_0x257424,_0x3e74cd,_0x555b4e)=>{const _0x80195a=_0x2eee9c;try{const {locator:_0x4c9d76,selector:_0x14160e,resolvedSelector:_0x4da0d4}=await _0x257424[_0x80195a(0xd0)](_0x3e74cd),_0x5b0d40={};_0x5b0d40['elementRef']=_0x3e74cd[_0x80195a(0xe5)],_0x5b0d40[_0x80195a(0xc1)]=_0x3e74cd[_0x80195a(0xad)],_0x5b0d40[_0x80195a(0xe7)]=_0x14160e,_0x5b0d40[_0x80195a(0xce)]=_0x4da0d4,_0x555b4e[_0x80195a(0xdc)](_0x5b0d40),await _0x4c9d76[_0x80195a(0xf8)](),_0x555b4e[_0x80195a(0xe3)]('await\x20page.'+await generateLocator(_0x4c9d76)+_0x80195a(0xfc)),_0x555b4e[_0x80195a(0x106)](_0x80195a(0xc7)),_0x555b4e[_0x80195a(0xd2)]();}catch(_0x1abc5f){_0x555b4e[_0x80195a(0xd1)](_0x80195a(0xf4)+_0x1abc5f);}}}),_0x365f3c={};_0x365f3c[_0x2eee9c(0xdb)]=_0x2eee9c(0xcf),_0x365f3c[_0x2eee9c(0xbc)]=_0x2eee9c(0xee),_0x365f3c[_0x2eee9c(0x103)]=_0x2eee9c(0xb6),_0x365f3c[_0x2eee9c(0xf6)]=elementSchema,_0x365f3c[_0x2eee9c(0xe8)]=_0x2eee9c(0xc2);const getInputValue=defineTabTool({'capability':_0x2eee9c(0xbe),'schema':_0x365f3c,'handle':async(_0x3edbb2,_0x117fea,_0x520481)=>{const _0x5d5562=_0x2eee9c;try{const _0x35a470=await _0x3edbb2[_0x5d5562(0xdf)](_0x117fea),_0x91cd71=await _0x35a470['inputValue']();_0x520481[_0x5d5562(0xe3)](_0x5d5562(0xd5)+await generateLocator(_0x35a470)+_0x5d5562(0xbb)),_0x520481[_0x5d5562(0x106)](_0x5d5562(0xcd)+_0x91cd71);}catch(_0x4e21dd){_0x520481[_0x5d5562(0xd1)](_0x5d5562(0xec)+_0x4e21dd);}}}),_0xfffcb1={};_0xfffcb1['name']=_0x2eee9c(0xca),_0xfffcb1[_0x2eee9c(0xbc)]=_0x2eee9c(0xb4),_0xfffcb1[_0x2eee9c(0x103)]=_0x2eee9c(0x104),_0xfffcb1[_0x2eee9c(0xf6)]=elementSchema,_0xfffcb1[_0x2eee9c(0xe8)]=_0x2eee9c(0xb7);const submitForm=defineTabTool({'capability':_0x2eee9c(0xbe),'schema':_0xfffcb1,'handle':async(_0x3c7699,_0x2943a2,_0x42ae90)=>{const _0x37c10a=_0x2eee9c,_0x2468c3={'MYBhh':function(_0x4f2a6b,_0x34eea6){return _0x4f2a6b(_0x34eea6);}};try{const _0x108578=await _0x3c7699[_0x37c10a(0xdf)](_0x2943a2);await _0x3c7699[_0x37c10a(0xf5)](async()=>{const _0x4f8428=_0x37c10a;await _0x108578[_0x4f8428(0xc6)](_0x59f08e=>_0x59f08e[_0x4f8428(0xef)]());}),_0x42ae90[_0x37c10a(0xe3)](_0x37c10a(0xd7)+await _0x2468c3[_0x37c10a(0xe0)](generateLocator,_0x108578)+_0x37c10a(0xe6)),_0x42ae90[_0x37c10a(0x106)](_0x37c10a(0xb5)),_0x42ae90[_0x37c10a(0xd2)]();}catch(_0x115f69){_0x42ae90[_0x37c10a(0xd1)](_0x37c10a(0x107)+_0x115f69);}}});export default[checkCheckbox,selectRadio,clearInput,getInputValue,submitForm];
|
package/lib/tools/getext.js
CHANGED
|
@@ -1,99 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Copyright (c) Microsoft Corpo handle: async (tab, params, response) => {
|
|
3
|
-
const { ref, element, attribute } = params;
|
|
4
|
-
|
|
5
|
-
try {
|
|
6
|
-
const locator = await tab.refLocator(params);
|
|
7
|
-
|
|
8
|
-
let result: string;
|
|
9
|
-
if (attribute) {
|
|
10
|
-
result = await locator.getAttribute(attribute) || '';
|
|
11
|
-
response.addCode(`const attributeValue = await page.${await generateLocator(locator)}.getAttribute('${attribute}');`);
|
|
12
|
-
} else {
|
|
13
|
-
result = await locator.textContent() || '';
|
|
14
|
-
response.addCode(`const textContent = await page.${await generateLocator(locator)}.textContent();`);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
response.addResult(`${attribute ? `Attribute "${attribute}"` : 'Text content'}: ${result}`);
|
|
18
|
-
} catch (error) {
|
|
19
|
-
response.addError(`Failed to get ${attribute ? `attribute "${attribute}"` : 'text content'} from element: ${error}`);
|
|
20
|
-
}
|
|
21
|
-
},ed under the Apache License, Version 2.0 (the "License");
|
|
22
|
-
* you may not use this file except in compliance with the License.
|
|
23
|
-
* You may obtain a copy of the License at
|
|
24
|
-
*
|
|
25
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
26
|
-
*
|
|
27
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
28
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
29
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
30
|
-
* See the License for the specific language governing permissions and
|
|
31
|
-
* limitations under the License.
|
|
32
|
-
*/
|
|
33
|
-
import { z } from 'zod';
|
|
34
|
-
import { defineTabTool } from './tool.js';
|
|
35
|
-
import { elementSchema } from './snapshot.js';
|
|
36
|
-
import { generateLocator } from './utils.js';
|
|
37
|
-
const getTextSchema = elementSchema.extend({
|
|
38
|
-
attribute: z.string().optional().describe('Optional attribute to get instead of text content (e.g., "href", "src", "value")'),
|
|
39
|
-
});
|
|
40
|
-
const getText = defineTabTool({
|
|
41
|
-
capability: 'core',
|
|
42
|
-
schema: {
|
|
43
|
-
name: 'browser_get_text',
|
|
44
|
-
title: 'Get text content or attribute from element',
|
|
45
|
-
description: 'Get text content or attribute value from a specific element on the page',
|
|
46
|
-
inputSchema: getTextSchema,
|
|
47
|
-
type: 'readOnly',
|
|
48
|
-
},
|
|
49
|
-
handle: async (tab, params, response) => {
|
|
50
|
-
const { ref, element, attribute } = params;
|
|
51
|
-
try {
|
|
52
|
-
const locator = await tab.refLocator(params);
|
|
53
|
-
let result;
|
|
54
|
-
if (attribute) {
|
|
55
|
-
result = await locator.getAttribute(attribute) || '';
|
|
56
|
-
response.addCode(`const attributeValue = await page.${await generateLocator(locator)}.getAttribute('${attribute}');`);
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
result = await locator.textContent() || '';
|
|
60
|
-
response.addCode(`const textContent = await page.${await generateLocator(locator)}.textContent();`);
|
|
61
|
-
}
|
|
62
|
-
response.addResult(`${attribute ? `Attribute "${attribute}"` : 'Text content'}: ${result}`);
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
response.addError(`Failed to get ${attribute ? `attribute "${attribute}"` : 'text content'} from element: ${error}`);
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
const getPageInfo = defineTabTool({
|
|
70
|
-
capability: 'core',
|
|
71
|
-
schema: {
|
|
72
|
-
name: 'browser_get_page_info',
|
|
73
|
-
title: 'Get page information',
|
|
74
|
-
description: 'Get basic information about the current page (title, URL, etc.)',
|
|
75
|
-
inputSchema: z.object({}),
|
|
76
|
-
type: 'readOnly',
|
|
77
|
-
},
|
|
78
|
-
handle: async (tab, params, response) => {
|
|
79
|
-
try {
|
|
80
|
-
const title = await tab.page.title();
|
|
81
|
-
const url = tab.page.url();
|
|
82
|
-
const viewport = tab.page.viewportSize();
|
|
83
|
-
response.addCode(`const title = await page.title();
|
|
84
|
-
const url = page.url();
|
|
85
|
-
const viewport = page.viewportSize();`);
|
|
86
|
-
response.addResult(`Page Information:
|
|
87
|
-
- Title: ${title}
|
|
88
|
-
- URL: ${url}
|
|
89
|
-
- Viewport: ${viewport ? `${viewport.width}x${viewport.height}` : 'Not set'}`);
|
|
90
|
-
}
|
|
91
|
-
catch (error) {
|
|
92
|
-
response.addError(`Failed to get page information: ${error}`);
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
});
|
|
96
|
-
export default [
|
|
97
|
-
getText,
|
|
98
|
-
getPageInfo
|
|
99
|
-
];
|
|
1
|
+
function _0x30c2(_0x1871ad,_0x1d9c44){_0x1871ad=_0x1871ad-0xa8;const _0x4ed213=_0x2123();let _0xcf35f=_0x4ed213[_0x1871ad];if(_0x30c2['toFfux']===undefined){var _0x33cf06=function(_0x3705c4){const _0x2b7e25='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x535fe6='',_0x48d3a0='',_0x2efac9=_0x535fe6+_0x33cf06;for(let _0x16970f=0x0,_0x3bf2e4,_0x4eaaee,_0x50f3e5=0x0;_0x4eaaee=_0x3705c4['charAt'](_0x50f3e5++);~_0x4eaaee&&(_0x3bf2e4=_0x16970f%0x4?_0x3bf2e4*0x40+_0x4eaaee:_0x4eaaee,_0x16970f++%0x4)?_0x535fe6+=_0x2efac9['charCodeAt'](_0x50f3e5+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0x3bf2e4>>(-0x2*_0x16970f&0x6)):_0x16970f:0x0){_0x4eaaee=_0x2b7e25['indexOf'](_0x4eaaee);}for(let _0x4ea931=0x0,_0x6e96af=_0x535fe6['length'];_0x4ea931<_0x6e96af;_0x4ea931++){_0x48d3a0+='%'+('00'+_0x535fe6['charCodeAt'](_0x4ea931)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x48d3a0);};_0x30c2['iyaWXH']=_0x33cf06,_0x30c2['mOqbuo']={},_0x30c2['toFfux']=!![];}const _0x21238a=_0x4ed213[0x0],_0x30c2ae=_0x1871ad+_0x21238a,_0x10e1ec=_0x30c2['mOqbuo'][_0x30c2ae];if(!_0x10e1ec){const _0x3d88bd=function(_0x428de3){this['xGEVnX']=_0x428de3,this['pHNtGK']=[0x1,0x0,0x0],this['MxXjGR']=function(){return'newState';},this['ihAHza']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['uNwSBW']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x3d88bd['prototype']['nFiBhe']=function(){const _0x5f707f=new RegExp(this['ihAHza']+this['uNwSBW']),_0x36af15=_0x5f707f['test'](this['MxXjGR']['toString']())?--this['pHNtGK'][0x1]:--this['pHNtGK'][0x0];return this['WBXhea'](_0x36af15);},_0x3d88bd['prototype']['WBXhea']=function(_0x1f0136){if(!Boolean(~_0x1f0136))return _0x1f0136;return this['ogftGM'](this['xGEVnX']);},_0x3d88bd['prototype']['ogftGM']=function(_0x3e312a){for(let _0x36a874=0x0,_0x43995e=this['pHNtGK']['length'];_0x36a874<_0x43995e;_0x36a874++){this['pHNtGK']['push'](Math['round'](Math['random']())),_0x43995e=this['pHNtGK']['length'];}return _0x3e312a(this['pHNtGK'][0x0]);},new _0x3d88bd(_0x30c2)['nFiBhe'](),_0xcf35f=_0x30c2['iyaWXH'](_0xcf35f),_0x30c2['mOqbuo'][_0x30c2ae]=_0xcf35f;}else _0xcf35f=_0x10e1ec;return _0xcf35f;}const _0x1b3de4=_0x30c2;(function(_0x18d9e2,_0xd6e6aa){const _0x57b1b2=_0x30c2,_0x45316a=_0x18d9e2();while(!![]){try{const _0x506297=parseInt(_0x57b1b2(0xd7))/0x1+parseInt(_0x57b1b2(0xda))/0x2+parseInt(_0x57b1b2(0xc6))/0x3+-parseInt(_0x57b1b2(0xdb))/0x4+parseInt(_0x57b1b2(0xae))/0x5*(parseInt(_0x57b1b2(0xba))/0x6)+-parseInt(_0x57b1b2(0xb4))/0x7+parseInt(_0x57b1b2(0xb5))/0x8*(-parseInt(_0x57b1b2(0xde))/0x9);if(_0x506297===_0xd6e6aa)break;else _0x45316a['push'](_0x45316a['shift']());}catch(_0x2180b1){_0x45316a['push'](_0x45316a['shift']());}}}(_0x2123,0x84bb1));const _0x33cf06=(function(){let _0x21fc67=!![];return function(_0xf313e9,_0x1e1616){const _0x482f98=_0x21fc67?function(){const _0xfe8284=_0x30c2;if(_0x1e1616){const _0x35a559=_0x1e1616[_0xfe8284(0xc8)](_0xf313e9,arguments);return _0x1e1616=null,_0x35a559;}}:function(){};return _0x21fc67=![],_0x482f98;};}()),_0xcf35f=_0x33cf06(this,function(){const _0x35b695=_0x30c2,_0x2d4e69={};_0x2d4e69['jNgQn']=_0x35b695(0xe0);const _0x4eff7=_0x2d4e69;return _0xcf35f[_0x35b695(0xa9)]()[_0x35b695(0xaa)](_0x4eff7[_0x35b695(0xbc)])[_0x35b695(0xa9)]()[_0x35b695(0xac)](_0xcf35f)[_0x35b695(0xaa)](_0x35b695(0xe0));});_0xcf35f();import{z}from'zod';import{defineTabTool}from'./tool.js';import{elementSchema}from'./snapshot.js';import{generateLocator}from'./utils.js';const getTextSchema=elementSchema[_0x1b3de4(0xd0)]({'attribute':z[_0x1b3de4(0xc9)]()[_0x1b3de4(0xca)]()[_0x1b3de4(0xb9)](_0x1b3de4(0xd4))}),_0x24ad43={};_0x24ad43[_0x1b3de4(0xcf)]=_0x1b3de4(0xcd),_0x24ad43[_0x1b3de4(0xd6)]=_0x1b3de4(0xb3),_0x24ad43[_0x1b3de4(0xc5)]=_0x1b3de4(0xc1),_0x24ad43[_0x1b3de4(0xc0)]=getTextSchema,_0x24ad43[_0x1b3de4(0xe3)]=_0x1b3de4(0xb7);function _0x2123(){const _0x4de35f=['kcGOlISPkYKRksSK','tM90ihnLDa','y29Yzq','DhLWzq','qxr0CMLIDxrLici','Dg9tDhjPBMC','C2vHCMnO','ywrKq29Kzq','y29UC3rYDwn0B3i','y29UC3qGDgv4DenVBNrLBNqGpsbHD2fPDcbWywDLlG','mZa4nvLtr0jmzG','CgfNzq','ugfNzsbjBMzVCM1HDgLVBJOklsbuAxrSztOG','Dgv4DenVBNrLBNq','DxjS','r2v0ihrLEhqGy29UDgvUDcbVCIbHDhrYAwj1DguGzNjVBsbLBgvTzw50','nJCZnty5nfLUB0jZsW','oenjEuL5AW','ywrKuMvZDwX0','CMvHze9UBhK','tKXoyMS','zgvZy3jPyMu','nJa1nezsvMLmDG','DMLLD3bVCNrtAxPL','AK5Nuw4','B2jQzwn0','ywrKrxjYB3i','yNjVD3nLCL9NzxrFCgfNzv9PBMzV','Aw5WDxrty2HLBwe','r2v0ihrLEhqGy29UDgvUDcbVCIbHDhrYAwj1DguGDMfSDwuGzNjVBsbHihnWzwnPzMLJigvSzw1LBNqGB24GDgHLihbHz2u','jYK7','CMnivhG','EgHwDvK','zgvZy3jPChrPB24','mJqYndm2oxP4Cvjdza','cI0GvvjmoIa','yxbWBhK','C3rYAw5N','B3b0Aw9UywW','rMfPBgvKihrVigDLDcbWywDLigLUzM9YBwf0Aw9UoIa','igzYB20GzwXLBwvUDdOG','yNjVD3nLCL9NzxrFDgv4Da','r2v0igjHC2LJigLUzM9YBwf0Aw9UigfIB3v0ihrOzsbJDxjYzw50ihbHz2uGkhrPDgXLlcbvuKWSigv0yY4P','BMfTzq','zxH0zw5K','lNrLEhrdB250zw50kcK7','Dgv4DcbJB250zw50','y29UC3qGDgL0BguGpsbHD2fPDcbWywDLlNrPDgXLkcK7cMnVBNn0ihvYBca9ihbHz2uUDxjSkcK7cMnVBNn0ihzPzxDWB3j0id0GCgfNzs52Awv3Cg9YDfnPEMuOktS','t3b0Aw9UywWGyxr0CMLIDxrLihrVigDLDcbPBNn0zwfKig9MihrLEhqGy29UDgvUDcaOzs5NlIWGiMHYzwyIlcaIC3jJiIWGiNzHBhvLiIK','rMfPBgvKihrVigDLDca','DgL0Bgu','nZa4ndy5AvLPrgvk','yxr0CMLIDxrLici','vgv4DcbJB250zw50','mti1mJy2nenwswXmsq','mZm1nJC2q1nZD2rk','cI0GvMLLD3bVCNq6ia','y29UC3qGyxr0CMLIDxrLvMfSDwuGpsbHD2fPDcbWywDLlG','mta1oda4ntLZuursv28','lMDLDef0DhjPyNv0zsGN'];_0x2123=function(){return _0x4de35f;};return _0x2123();}const getText=defineTabTool({'capability':_0x1b3de4(0xe2),'schema':_0x24ad43,'handle':async(_0x4935c4,_0x40005c,_0x1b2219)=>{const _0x4fb8d9=_0x1b3de4,_0xae766={'NLNbk':function(_0x18926d,_0x353778){return _0x18926d(_0x353778);},'xhVuY':_0x4fb8d9(0xd9)},{ref:_0x207848,element:_0x4fe2da,attribute:_0x2f85c9}=_0x40005c;try{const _0x22826e=await _0x4935c4['refLocator'](_0x40005c);let _0x4db685;_0x2f85c9?(_0x4db685=await _0x22826e['getAttribute'](_0x2f85c9)||'',_0x1b2219['addCode'](_0x4fb8d9(0xdd)+await _0xae766[_0x4fb8d9(0xb8)](generateLocator,_0x22826e)+_0x4fb8d9(0xdf)+_0x2f85c9+_0x4fb8d9(0xc2))):(_0x4db685=await _0x22826e[_0x4fb8d9(0xb1)]()||'',_0x1b2219[_0x4fb8d9(0xab)](_0x4fb8d9(0xad)+await _0xae766[_0x4fb8d9(0xb8)](generateLocator,_0x22826e)+_0x4fb8d9(0xd1))),_0x1b2219[_0x4fb8d9(0xb6)]((_0x2f85c9?_0x4fb8d9(0xa8)+_0x2f85c9+'\x22':_0xae766[_0x4fb8d9(0xc4)])+':\x20'+_0x4db685);}catch(_0x484ac1){_0x1b2219[_0x4fb8d9(0xbe)](_0x4fb8d9(0xd5)+(_0x2f85c9?_0x4fb8d9(0xd8)+_0x2f85c9+'\x22':_0x4fb8d9(0xd2))+_0x4fb8d9(0xcc)+_0x484ac1);}}}),getPageInfo=defineTabTool({'capability':_0x1b3de4(0xe2),'schema':{'name':_0x1b3de4(0xbf),'title':'Get\x20page\x20information','description':_0x1b3de4(0xce),'inputSchema':z[_0x1b3de4(0xbd)]({}),'type':_0x1b3de4(0xb7)},'handle':async(_0x130258,_0x533d5e,_0x234ced)=>{const _0x26cd51=_0x1b3de4,_0x2a03a8={};_0x2a03a8[_0x26cd51(0xc3)]=_0x26cd51(0xe1);const _0x1023b6=_0x2a03a8;try{const _0x220c15=await _0x130258[_0x26cd51(0xaf)][_0x26cd51(0xd6)](),_0x4e02c3=_0x130258[_0x26cd51(0xaf)][_0x26cd51(0xb2)](),_0x292292=_0x130258[_0x26cd51(0xaf)][_0x26cd51(0xbb)]();_0x234ced['addCode'](_0x26cd51(0xd3)),_0x234ced['addResult'](_0x26cd51(0xb0)+_0x220c15+_0x26cd51(0xc7)+_0x4e02c3+_0x26cd51(0xdc)+(_0x292292?_0x292292['width']+'x'+_0x292292['height']:_0x1023b6[_0x26cd51(0xc3)]));}catch(_0x32070a){_0x234ced[_0x26cd51(0xbe)](_0x26cd51(0xcb)+_0x32070a);}}});export default[getText,getPageInfo];
|
package/lib/tools/install.js
CHANGED
|
@@ -1,53 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Copyright (c) Microsoft Corporation.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { fork } from 'child_process';
|
|
17
|
-
import path from 'path';
|
|
18
|
-
import { fileURLToPath } from 'url';
|
|
19
|
-
import { z } from 'zod';
|
|
20
|
-
import { defineTool } from './tool.js';
|
|
21
|
-
const install = defineTool({
|
|
22
|
-
capability: 'core-install',
|
|
23
|
-
schema: {
|
|
24
|
-
name: 'browser_install',
|
|
25
|
-
title: 'Install the browser specified in the config',
|
|
26
|
-
description: 'Install the browser specified in the config. Call this if you get an error about the browser not being installed.',
|
|
27
|
-
inputSchema: z.object({}),
|
|
28
|
-
type: 'destructive',
|
|
29
|
-
},
|
|
30
|
-
handle: async (context, params, response) => {
|
|
31
|
-
const channel = context.config.browser?.launchOptions?.channel ?? context.config.browser?.browserName ?? 'chrome';
|
|
32
|
-
const cliUrl = import.meta.resolve('playwright/package.json');
|
|
33
|
-
const cliPath = path.join(fileURLToPath(cliUrl), '..', 'cli.js');
|
|
34
|
-
const child = fork(cliPath, ['install', channel], {
|
|
35
|
-
stdio: 'pipe',
|
|
36
|
-
});
|
|
37
|
-
const output = [];
|
|
38
|
-
child.stdout?.on('data', data => output.push(data.toString()));
|
|
39
|
-
child.stderr?.on('data', data => output.push(data.toString()));
|
|
40
|
-
await new Promise((resolve, reject) => {
|
|
41
|
-
child.on('close', code => {
|
|
42
|
-
if (code === 0)
|
|
43
|
-
resolve();
|
|
44
|
-
else
|
|
45
|
-
reject(new Error(`Failed to install browser: ${output.join('')}`));
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
response.setIncludeTabs();
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
export default [
|
|
52
|
-
install,
|
|
53
|
-
];
|
|
1
|
+
const _0x363d0d=_0x5c29;(function(_0x56805a,_0xf53316){const _0x1c5123=_0x5c29,_0x5b871a=_0x56805a();while(!![]){try{const _0x31f851=parseInt(_0x1c5123(0x171))/0x1+parseInt(_0x1c5123(0x183))/0x2+-parseInt(_0x1c5123(0x196))/0x3+parseInt(_0x1c5123(0x177))/0x4+-parseInt(_0x1c5123(0x184))/0x5*(-parseInt(_0x1c5123(0x16e))/0x6)+parseInt(_0x1c5123(0x16d))/0x7*(parseInt(_0x1c5123(0x180))/0x8)+-parseInt(_0x1c5123(0x17b))/0x9;if(_0x31f851===_0xf53316)break;else _0x5b871a['push'](_0x5b871a['shift']());}catch(_0x5691b5){_0x5b871a['push'](_0x5b871a['shift']());}}}(_0x47b7,0x49472));const _0x1fc84d=(function(){let _0x1861f1=!![];return function(_0x77fed2,_0x30ace5){const _0x26723e=_0x1861f1?function(){const _0x539ee5=_0x5c29;if(_0x30ace5){const _0x391458=_0x30ace5[_0x539ee5(0x18a)](_0x77fed2,arguments);return _0x30ace5=null,_0x391458;}}:function(){};return _0x1861f1=![],_0x26723e;};}()),_0x4c2a99=_0x1fc84d(this,function(){const _0x56bb06=_0x5c29,_0x1a2f99={};_0x1a2f99[_0x56bb06(0x17c)]=_0x56bb06(0x17e);const _0x8cfd49=_0x1a2f99;return _0x4c2a99[_0x56bb06(0x193)]()[_0x56bb06(0x191)](_0x8cfd49[_0x56bb06(0x17c)])[_0x56bb06(0x193)]()[_0x56bb06(0x17f)](_0x4c2a99)[_0x56bb06(0x191)](_0x8cfd49['jFCRv']);});_0x4c2a99();function _0x47b7(){const _0x38af33=['yNjVD3nLCK5HBwu','C3rKzxjY','D2T1Dwe','mZm2mdiXtufHweLj','mtGXogrWDLbOBW','y2XVC2u','Ae1gBvG','ntK2mtvsBwXWteS','Aw5ZDgfSBa','C3rKB3v0','sw5ZDgfSBcb0AguGyNjVD3nLCIbZCgvJAwzPzwqGAw4GDgHLignVBMzPzW','s2nJBuK','AM9PBG','mtm4mZG2neDTuhfIDa','Bgf1BMnOt3b0Aw9UCW','yNjVD3nLCG','ChvZAa','ndaWmtK1ogflqvv6sG','AKzduNy','zgf0yq','kcGOlISPkYKRksSK','y29UC3rYDwn0B3i','odHyrwz0D2y','vwzPzMi','C2v0sw5JBhvKzvrHyNm','mtHKDhzuu0q','mZy2nxvrv3vtDq','CgLWzq','tur3ywO','zgvZDhj1y3rPDMu','CgXHExDYAwDODc9WywnRywDLlMPZB24','yNjVD3nLCL9PBNn0ywXS','yxbWBhK','y29UzMLN','zwzsAgO','y29Yzs1PBNn0ywXS','y2HYB21L','y2XPlMPZ','rLbxvgO','C2vHCMnO','rMfPBgvKihrVigLUC3rHBgWGyNjVD3nLCJOG','Dg9tDhjPBMC','sw5ZDgfSBcb0AguGyNjVD3nLCIbZCgvJAwzPzwqGAw4GDgHLignVBMzPzY4Gq2fSBcb0AgLZigLMihLVDsbNzxqGyw4GzxjYB3iGywjVDxqGDgHLigjYB3DZzxiGBM90igjLAw5NigLUC3rHBgXLzc4','B2jQzwn0','mtiZmJC0mNrfz2Hdua','B3rvs0S'];_0x47b7=function(){return _0x38af33;};return _0x47b7();}import{fork}from'child_process';import _0x3bd263 from'path';function _0x5c29(_0x61904,_0x5445b6){_0x61904=_0x61904-0x16d;const _0x56ae50=_0x47b7();let _0x4c2a99=_0x56ae50[_0x61904];if(_0x5c29['XjMBuE']===undefined){var _0x1fc84d=function(_0x2e3794){const _0x352175='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x22065a='',_0x435f55='',_0x12ef93=_0x22065a+_0x1fc84d;for(let _0x5cab20=0x0,_0x333726,_0x3a6293,_0x24e468=0x0;_0x3a6293=_0x2e3794['charAt'](_0x24e468++);~_0x3a6293&&(_0x333726=_0x5cab20%0x4?_0x333726*0x40+_0x3a6293:_0x3a6293,_0x5cab20++%0x4)?_0x22065a+=_0x12ef93['charCodeAt'](_0x24e468+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0x333726>>(-0x2*_0x5cab20&0x6)):_0x5cab20:0x0){_0x3a6293=_0x352175['indexOf'](_0x3a6293);}for(let _0x97bbd1=0x0,_0x50b9f1=_0x22065a['length'];_0x97bbd1<_0x50b9f1;_0x97bbd1++){_0x435f55+='%'+('00'+_0x22065a['charCodeAt'](_0x97bbd1)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x435f55);};_0x5c29['SiPbPa']=_0x1fc84d,_0x5c29['KGXqFX']={},_0x5c29['XjMBuE']=!![];}const _0x47b72e=_0x56ae50[0x0],_0x5c299f=_0x61904+_0x47b72e,_0x49deb8=_0x5c29['KGXqFX'][_0x5c299f];if(!_0x49deb8){const _0xb383e3=function(_0x543576){this['ioXczc']=_0x543576,this['ZPErYm']=[0x1,0x0,0x0],this['lZqiDV']=function(){return'newState';},this['TOOVIn']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['rMULHC']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0xb383e3['prototype']['sEjprH']=function(){const _0x271621=new RegExp(this['TOOVIn']+this['rMULHC']),_0x54226f=_0x271621['test'](this['lZqiDV']['toString']())?--this['ZPErYm'][0x1]:--this['ZPErYm'][0x0];return this['vHlFvF'](_0x54226f);},_0xb383e3['prototype']['vHlFvF']=function(_0x1f03c4){if(!Boolean(~_0x1f03c4))return _0x1f03c4;return this['fYZrwt'](this['ioXczc']);},_0xb383e3['prototype']['fYZrwt']=function(_0x3cf766){for(let _0x48b8a9=0x0,_0x5eeaae=this['ZPErYm']['length'];_0x48b8a9<_0x5eeaae;_0x48b8a9++){this['ZPErYm']['push'](Math['round'](Math['random']())),_0x5eeaae=this['ZPErYm']['length'];}return _0x3cf766(this['ZPErYm'][0x0]);},new _0xb383e3(_0x5c29)['sEjprH'](),_0x4c2a99=_0x5c29['SiPbPa'](_0x4c2a99),_0x5c29['KGXqFX'][_0x5c299f]=_0x4c2a99;}else _0x4c2a99=_0x49deb8;return _0x4c2a99;}import{fileURLToPath}from'url';import{z}from'zod';import{defineTool}from'./tool.js';const install=defineTool({'capability':_0x363d0d(0x18d),'schema':{'name':_0x363d0d(0x189),'title':_0x363d0d(0x174),'description':_0x363d0d(0x194),'inputSchema':z[_0x363d0d(0x195)]({}),'type':_0x363d0d(0x187)},'handle':async(_0x739df4,_0x27fcc0,_0x139968)=>{const _0x3acbbb=_0x363d0d,_0x1c23f2={'KccmI':function(_0xa5a8b7){return _0xa5a8b7();},'Ufifb':function(_0x17f77d,_0x5afc2e){return _0x17f77d(_0x5afc2e);},'hMFmX':_0x3acbbb(0x16f),'MDwaj':_0x3acbbb(0x18e),'OQfnt':function(_0x15645d,_0x5c5535){return _0x15645d(_0x5c5535);},'wkuua':_0x3acbbb(0x18f),'otUKK':function(_0x301452,_0x251524,_0x13d47a,_0x19c19d){return _0x301452(_0x251524,_0x13d47a,_0x19c19d);},'efRhj':_0x3acbbb(0x185),'FPWTj':_0x3acbbb(0x17d)},_0x54ce34=_0x739df4[_0x3acbbb(0x18b)][_0x3acbbb(0x179)]?.[_0x3acbbb(0x178)]?.['channel']??_0x739df4[_0x3acbbb(0x18b)]['browser']?.[_0x3acbbb(0x198)]??_0x1c23f2[_0x3acbbb(0x186)],_0x57a588=import.meta.resolve(_0x3acbbb(0x188)),_0x2488c4=_0x3bd263[_0x3acbbb(0x176)](_0x1c23f2['OQfnt'](fileURLToPath,_0x57a588),'..',_0x1c23f2[_0x3acbbb(0x19a)]),_0xb16845=_0x1c23f2[_0x3acbbb(0x197)](fork,_0x2488c4,[_0x3acbbb(0x172),_0x54ce34],{'stdio':_0x1c23f2[_0x3acbbb(0x18c)]}),_0x56bf74=[];_0xb16845[_0x3acbbb(0x173)]?.['on'](_0x1c23f2[_0x3acbbb(0x190)],_0x1766aa=>_0x56bf74[_0x3acbbb(0x17a)](_0x1766aa[_0x3acbbb(0x193)]())),_0xb16845[_0x3acbbb(0x199)]?.['on'](_0x1c23f2[_0x3acbbb(0x190)],_0x3df01d=>_0x56bf74[_0x3acbbb(0x17a)](_0x3df01d[_0x3acbbb(0x193)]())),await new Promise((_0x27b56b,_0xde0b3d)=>{const _0x88d8d6=_0x3acbbb;_0xb16845['on'](_0x1c23f2[_0x88d8d6(0x170)],_0x13876c=>{const _0x53add9=_0x88d8d6;if(_0x13876c===0x0)_0x1c23f2[_0x53add9(0x175)](_0x27b56b);else _0x1c23f2[_0x53add9(0x181)](_0xde0b3d,new Error(_0x53add9(0x192)+_0x56bf74[_0x53add9(0x176)]('')));});}),_0x139968[_0x3acbbb(0x182)]();}});export default[install];
|
|
@@ -1,191 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Microsoft Corporation.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { z } from 'zod';
|
|
17
|
-
import { defineTabTool } from './tool.js';
|
|
18
|
-
import { elementSchema } from './snapshot.js';
|
|
19
|
-
import { generateLocator } from './utils.js';
|
|
20
|
-
// Scroll to element or position
|
|
21
|
-
const scrollTo = defineTabTool({
|
|
22
|
-
capability: 'core',
|
|
23
|
-
schema: {
|
|
24
|
-
name: 'browser_scroll_to',
|
|
25
|
-
title: 'Scroll to element or position',
|
|
26
|
-
description: 'Scroll to a specific element or coordinate position',
|
|
27
|
-
inputSchema: z.object({
|
|
28
|
-
element: z.string().optional().describe('Human-readable element description (if scrolling to element)'),
|
|
29
|
-
ref: z.string().optional().describe('Element reference (if scrolling to element)'),
|
|
30
|
-
x: z.number().optional().describe('X coordinate to scroll to (if scrolling to position)'),
|
|
31
|
-
y: z.number().optional().describe('Y coordinate to scroll to (if scrolling to position)'),
|
|
32
|
-
behavior: z.enum(['auto', 'smooth']).optional().default('auto').describe('Scroll behavior'),
|
|
33
|
-
}),
|
|
34
|
-
type: 'destructive',
|
|
35
|
-
},
|
|
36
|
-
handle: async (tab, params, response) => {
|
|
37
|
-
try {
|
|
38
|
-
if (params.element && params.ref) {
|
|
39
|
-
// Scroll to element
|
|
40
|
-
const locator = await tab.refLocator({ element: params.element, ref: params.ref });
|
|
41
|
-
await locator.scrollIntoViewIfNeeded();
|
|
42
|
-
response.addCode(`await page.${await generateLocator(locator)}.scrollIntoViewIfNeeded();`);
|
|
43
|
-
response.addResult('Scrolled to element successfully');
|
|
44
|
-
}
|
|
45
|
-
else if (params.x !== undefined && params.y !== undefined) {
|
|
46
|
-
// Scroll to coordinates
|
|
47
|
-
await tab.page.evaluate(({ x, y, behavior }) => {
|
|
48
|
-
window.scrollTo({ left: x, top: y, behavior });
|
|
49
|
-
}, { x: params.x, y: params.y, behavior: params.behavior });
|
|
50
|
-
response.addCode(`await page.evaluate(() => window.scrollTo({ left: ${params.x}, top: ${params.y}, behavior: '${params.behavior}' }));`);
|
|
51
|
-
response.addResult(`Scrolled to position (${params.x}, ${params.y})`);
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
response.addError('Either provide element+ref OR x+y coordinates');
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
response.setIncludeSnapshot();
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
response.addError(`Failed to scroll: ${error}`);
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
// Get page scroll position
|
|
65
|
-
const getScrollPosition = defineTabTool({
|
|
66
|
-
capability: 'core',
|
|
67
|
-
schema: {
|
|
68
|
-
name: 'browser_get_scroll_position',
|
|
69
|
-
title: 'Get scroll position',
|
|
70
|
-
description: 'Get the current scroll position of the page',
|
|
71
|
-
inputSchema: z.object({}),
|
|
72
|
-
type: 'readOnly',
|
|
73
|
-
},
|
|
74
|
-
handle: async (tab, params, response) => {
|
|
75
|
-
try {
|
|
76
|
-
const position = await tab.page.evaluate(() => ({
|
|
77
|
-
x: window.scrollX,
|
|
78
|
-
y: window.scrollY,
|
|
79
|
-
}));
|
|
80
|
-
response.addCode(`const position = await page.evaluate(() => ({ x: window.scrollX, y: window.scrollY }));`);
|
|
81
|
-
response.addResult(`Current scroll position: x=${position.x}, y=${position.y}`);
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
response.addError(`Failed to get scroll position: ${error}`);
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
});
|
|
88
|
-
// Focus on element
|
|
89
|
-
const focusElement = defineTabTool({
|
|
90
|
-
capability: 'core',
|
|
91
|
-
schema: {
|
|
92
|
-
name: 'browser_focus_element',
|
|
93
|
-
title: 'Focus on element',
|
|
94
|
-
description: 'Set focus on a specific element',
|
|
95
|
-
inputSchema: elementSchema,
|
|
96
|
-
type: 'destructive',
|
|
97
|
-
},
|
|
98
|
-
handle: async (tab, params, response) => {
|
|
99
|
-
try {
|
|
100
|
-
const locator = await tab.refLocator(params);
|
|
101
|
-
await locator.focus();
|
|
102
|
-
response.addCode(`await page.${await generateLocator(locator)}.focus();`);
|
|
103
|
-
response.addResult('Element focused successfully');
|
|
104
|
-
response.setIncludeSnapshot();
|
|
105
|
-
}
|
|
106
|
-
catch (error) {
|
|
107
|
-
response.addError(`Failed to focus element: ${error}`);
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
});
|
|
111
|
-
// Blur (remove focus from) element
|
|
112
|
-
const blurElement = defineTabTool({
|
|
113
|
-
capability: 'core',
|
|
114
|
-
schema: {
|
|
115
|
-
name: 'browser_blur_element',
|
|
116
|
-
title: 'Remove focus from element',
|
|
117
|
-
description: 'Remove focus from a specific element',
|
|
118
|
-
inputSchema: elementSchema,
|
|
119
|
-
type: 'destructive',
|
|
120
|
-
},
|
|
121
|
-
handle: async (tab, params, response) => {
|
|
122
|
-
try {
|
|
123
|
-
const locator = await tab.refLocator(params);
|
|
124
|
-
await locator.blur();
|
|
125
|
-
response.addCode(`await page.${await generateLocator(locator)}.blur();`);
|
|
126
|
-
response.addResult('Element blurred successfully');
|
|
127
|
-
response.setIncludeSnapshot();
|
|
128
|
-
}
|
|
129
|
-
catch (error) {
|
|
130
|
-
response.addError(`Failed to blur element: ${error}`);
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
});
|
|
134
|
-
// Double click
|
|
135
|
-
const doubleClick = defineTabTool({
|
|
136
|
-
capability: 'core',
|
|
137
|
-
schema: {
|
|
138
|
-
name: 'browser_double_click',
|
|
139
|
-
title: 'Double click element',
|
|
140
|
-
description: 'Perform a double click on an element',
|
|
141
|
-
inputSchema: elementSchema,
|
|
142
|
-
type: 'destructive',
|
|
143
|
-
},
|
|
144
|
-
handle: async (tab, params, response) => {
|
|
145
|
-
try {
|
|
146
|
-
const locator = await tab.refLocator(params);
|
|
147
|
-
await tab.waitForCompletion(async () => {
|
|
148
|
-
await locator.dblclick();
|
|
149
|
-
});
|
|
150
|
-
response.addCode(`await page.${await generateLocator(locator)}.dblclick();`);
|
|
151
|
-
response.addResult('Double click performed successfully');
|
|
152
|
-
response.setIncludeSnapshot();
|
|
153
|
-
}
|
|
154
|
-
catch (error) {
|
|
155
|
-
response.addError(`Failed to double click: ${error}`);
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
|
-
});
|
|
159
|
-
// Right click (context menu)
|
|
160
|
-
const rightClick = defineTabTool({
|
|
161
|
-
capability: 'core',
|
|
162
|
-
schema: {
|
|
163
|
-
name: 'browser_right_click',
|
|
164
|
-
title: 'Right click element',
|
|
165
|
-
description: 'Perform a right click on an element to open context menu',
|
|
166
|
-
inputSchema: elementSchema,
|
|
167
|
-
type: 'destructive',
|
|
168
|
-
},
|
|
169
|
-
handle: async (tab, params, response) => {
|
|
170
|
-
try {
|
|
171
|
-
const locator = await tab.refLocator(params);
|
|
172
|
-
await tab.waitForCompletion(async () => {
|
|
173
|
-
await locator.click({ button: 'right' });
|
|
174
|
-
});
|
|
175
|
-
response.addCode(`await page.${await generateLocator(locator)}.click({ button: 'right' });`);
|
|
176
|
-
response.addResult('Right click performed successfully');
|
|
177
|
-
response.setIncludeSnapshot();
|
|
178
|
-
}
|
|
179
|
-
catch (error) {
|
|
180
|
-
response.addError(`Failed to right click: ${error}`);
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
});
|
|
184
|
-
export default [
|
|
185
|
-
scrollTo,
|
|
186
|
-
getScrollPosition,
|
|
187
|
-
focusElement,
|
|
188
|
-
blurElement,
|
|
189
|
-
doubleClick,
|
|
190
|
-
rightClick,
|
|
191
|
-
];
|
|
1
|
+
const _0xf53e65=_0x2965;(function(_0x245fa6,_0x27f126){const _0x3ae69d=_0x2965,_0x5bf00a=_0x245fa6();while(!![]){try{const _0x35891a=parseInt(_0x3ae69d(0xc6))/0x1+parseInt(_0x3ae69d(0x7d))/0x2*(-parseInt(_0x3ae69d(0x97))/0x3)+-parseInt(_0x3ae69d(0x9f))/0x4*(parseInt(_0x3ae69d(0x9b))/0x5)+-parseInt(_0x3ae69d(0xa9))/0x6+-parseInt(_0x3ae69d(0xb5))/0x7+-parseInt(_0x3ae69d(0xbe))/0x8*(-parseInt(_0x3ae69d(0x8f))/0x9)+parseInt(_0x3ae69d(0xd7))/0xa;if(_0x35891a===_0x27f126)break;else _0x5bf00a['push'](_0x5bf00a['shift']());}catch(_0x3a5a11){_0x5bf00a['push'](_0x5bf00a['shift']());}}}(_0xef08,0x53998));const _0x1478f6=(function(){let _0x537c97=!![];return function(_0xa48d5a,_0x38defe){const _0x315a6f=_0x537c97?function(){const _0x4c540a=_0x2965;if(_0x38defe){const _0x3a8a6a=_0x38defe[_0x4c540a(0xa1)](_0xa48d5a,arguments);return _0x38defe=null,_0x3a8a6a;}}:function(){};return _0x537c97=![],_0x315a6f;};}()),_0x4c0e1a=_0x1478f6(this,function(){const _0x565906=_0x2965;return _0x4c0e1a[_0x565906(0xc7)]()[_0x565906(0x85)](_0x565906(0x88))[_0x565906(0xc7)]()[_0x565906(0xc8)](_0x4c0e1a)[_0x565906(0x85)](_0x565906(0x88));});_0x4c0e1a();import{z}from'zod';import{defineTabTool}from'./tool.js';import{elementSchema}from'./snapshot.js';import{generateLocator}from'./utils.js';const scrollTo=defineTabTool({'capability':_0xf53e65(0xcd),'schema':{'name':_0xf53e65(0xdb),'title':_0xf53e65(0xbf),'description':_0xf53e65(0x78),'inputSchema':z[_0xf53e65(0xbc)]({'element':z[_0xf53e65(0xdc)]()[_0xf53e65(0x81)]()[_0xf53e65(0x9a)](_0xf53e65(0x92)),'ref':z[_0xf53e65(0xdc)]()[_0xf53e65(0x81)]()[_0xf53e65(0x9a)](_0xf53e65(0x7f)),'x':z[_0xf53e65(0x93)]()[_0xf53e65(0x81)]()[_0xf53e65(0x9a)](_0xf53e65(0xa6)),'y':z[_0xf53e65(0x93)]()[_0xf53e65(0x81)]()[_0xf53e65(0x9a)](_0xf53e65(0x7b)),'behavior':z[_0xf53e65(0x8c)]([_0xf53e65(0xb2),_0xf53e65(0xda)])[_0xf53e65(0x81)]()[_0xf53e65(0xce)](_0xf53e65(0xb2))[_0xf53e65(0x9a)](_0xf53e65(0xab))}),'type':'destructive'},'handle':async(_0x5d8bc5,_0x16a1f1,_0x316a74)=>{const _0x1ae585=_0xf53e65,_0x9be662={'celaK':function(_0x24d28c,_0x2f9d37){return _0x24d28c(_0x2f9d37);},'zkkVY':_0x1ae585(0xcb),'Fiysx':function(_0x73ea55,_0x19dda3){return _0x73ea55!==_0x19dda3;},'oVfss':function(_0x5019ae,_0x44c1c8){return _0x5019ae!==_0x44c1c8;},'PyCkc':_0x1ae585(0xca)};try{if(_0x16a1f1[_0x1ae585(0xb4)]&&_0x16a1f1[_0x1ae585(0x7a)]){const _0x4b1a31={};_0x4b1a31['element']=_0x16a1f1[_0x1ae585(0xb4)],_0x4b1a31[_0x1ae585(0x7a)]=_0x16a1f1[_0x1ae585(0x7a)];const _0xc3042a=await _0x5d8bc5[_0x1ae585(0xb6)](_0x4b1a31);await _0xc3042a[_0x1ae585(0x9d)](),_0x316a74[_0x1ae585(0x87)](_0x1ae585(0x91)+await _0x9be662[_0x1ae585(0xa8)](generateLocator,_0xc3042a)+'.scrollIntoViewIfNeeded();'),_0x316a74[_0x1ae585(0x8e)](_0x9be662['zkkVY']);}else{if(_0x9be662['Fiysx'](_0x16a1f1['x'],undefined)&&_0x9be662[_0x1ae585(0x9c)](_0x16a1f1['y'],undefined)){const _0x410a22={};_0x410a22['x']=_0x16a1f1['x'],_0x410a22['y']=_0x16a1f1['y'],_0x410a22[_0x1ae585(0xd0)]=_0x16a1f1[_0x1ae585(0xd0)],await _0x5d8bc5[_0x1ae585(0x82)]['evaluate'](({x:_0x40c833,y:_0x1f4bd5,behavior:_0x1373c5})=>{const _0x5edf0e=_0x1ae585,_0x464866={};_0x464866[_0x5edf0e(0xad)]=_0x40c833,_0x464866[_0x5edf0e(0xbd)]=_0x1f4bd5,_0x464866['behavior']=_0x1373c5,window[_0x5edf0e(0xae)](_0x464866);},_0x410a22),_0x316a74[_0x1ae585(0x87)](_0x1ae585(0x96)+_0x16a1f1['x']+_0x1ae585(0x95)+_0x16a1f1['y']+',\x20behavior:\x20\x27'+_0x16a1f1[_0x1ae585(0xd0)]+_0x1ae585(0xaf)),_0x316a74[_0x1ae585(0x8e)](_0x1ae585(0x7c)+_0x16a1f1['x']+',\x20'+_0x16a1f1['y']+')');}else{_0x316a74['addError'](_0x9be662['PyCkc']);return;}}_0x316a74['setIncludeSnapshot']();}catch(_0xf875da){_0x316a74[_0x1ae585(0xd4)](_0x1ae585(0xd5)+_0xf875da);}}}),getScrollPosition=defineTabTool({'capability':_0xf53e65(0xcd),'schema':{'name':_0xf53e65(0xc2),'title':'Get\x20scroll\x20position','description':_0xf53e65(0xa0),'inputSchema':z[_0xf53e65(0xbc)]({}),'type':_0xf53e65(0x79)},'handle':async(_0x56427f,_0x5108eb,_0x26030a)=>{const _0x55aee0=_0xf53e65;try{const _0x44dad5=await _0x56427f[_0x55aee0(0x82)]['evaluate'](()=>({'x':window[_0x55aee0(0xc0)],'y':window[_0x55aee0(0x90)]}));_0x26030a[_0x55aee0(0x87)](_0x55aee0(0x75)),_0x26030a[_0x55aee0(0x8e)](_0x55aee0(0xd1)+_0x44dad5['x']+_0x55aee0(0xb9)+_0x44dad5['y']);}catch(_0x3395de){_0x26030a[_0x55aee0(0xd4)]('Failed\x20to\x20get\x20scroll\x20position:\x20'+_0x3395de);}}}),_0x51361e={};_0x51361e[_0xf53e65(0x7e)]=_0xf53e65(0xc4),_0x51361e[_0xf53e65(0x9e)]=_0xf53e65(0xb8),_0x51361e[_0xf53e65(0xb7)]='Set\x20focus\x20on\x20a\x20specific\x20element',_0x51361e[_0xf53e65(0x77)]=elementSchema,_0x51361e[_0xf53e65(0xac)]=_0xf53e65(0x94);const focusElement=defineTabTool({'capability':_0xf53e65(0xcd),'schema':_0x51361e,'handle':async(_0x4c95e7,_0x385880,_0x2d6212)=>{const _0x350df6=_0xf53e65,_0x112cb8={};_0x112cb8[_0x350df6(0xa7)]=_0x350df6(0xd3);const _0xcb0d85=_0x112cb8;try{const _0x39fbfb=await _0x4c95e7[_0x350df6(0xb6)](_0x385880);await _0x39fbfb[_0x350df6(0xd2)](),_0x2d6212[_0x350df6(0x87)](_0x350df6(0x91)+await generateLocator(_0x39fbfb)+_0x350df6(0xcf)),_0x2d6212[_0x350df6(0x8e)](_0xcb0d85['JZtNg']),_0x2d6212[_0x350df6(0xdd)]();}catch(_0x20b572){_0x2d6212[_0x350df6(0xd4)](_0x350df6(0xa5)+_0x20b572);}}}),_0x57e8bc={};_0x57e8bc[_0xf53e65(0x7e)]=_0xf53e65(0xcc),_0x57e8bc[_0xf53e65(0x9e)]=_0xf53e65(0xa3),_0x57e8bc[_0xf53e65(0xb7)]=_0xf53e65(0x8d),_0x57e8bc[_0xf53e65(0x77)]=elementSchema,_0x57e8bc[_0xf53e65(0xac)]=_0xf53e65(0x94);const blurElement=defineTabTool({'capability':'core','schema':_0x57e8bc,'handle':async(_0x3bc114,_0x436286,_0x589487)=>{const _0x28e8cf=_0xf53e65,_0x5989ae={'JuTdv':function(_0x5c34d6,_0x146295){return _0x5c34d6(_0x146295);},'QanNN':_0x28e8cf(0x76)};try{const _0x5e6342=await _0x3bc114[_0x28e8cf(0xb6)](_0x436286);await _0x5e6342[_0x28e8cf(0xb0)](),_0x589487[_0x28e8cf(0x87)](_0x28e8cf(0x91)+await _0x5989ae[_0x28e8cf(0xd9)](generateLocator,_0x5e6342)+_0x28e8cf(0xc1)),_0x589487[_0x28e8cf(0x8e)](_0x5989ae[_0x28e8cf(0x99)]),_0x589487[_0x28e8cf(0xdd)]();}catch(_0xa9ab74){_0x589487[_0x28e8cf(0xd4)](_0x28e8cf(0xd8)+_0xa9ab74);}}}),_0x480ffd={};_0x480ffd[_0xf53e65(0x7e)]='browser_double_click',_0x480ffd['title']=_0xf53e65(0xb3),_0x480ffd[_0xf53e65(0xb7)]=_0xf53e65(0x83),_0x480ffd[_0xf53e65(0x77)]=elementSchema,_0x480ffd[_0xf53e65(0xac)]=_0xf53e65(0x94);function _0xef08(){const _0x335373=['AKjqwvC','ywrKq29Kzq','kcGOlISPkYKRksSK','D2fPDezVCKnVBxbSzxrPB24','y2XPy2S','CMLNAhq','zw51Bq','uMvTB3zLigzVy3vZigzYB20GysbZCgvJAwzPyYbLBgvTzw50','ywrKuMvZDwX0','mtu3ndq2AhDiCxr3','C2nYB2XSwq','yxDHAxqGCgfNzs4','shvTyw4TCMvHzgfIBguGzwXLBwvUDcbKzxnJCMLWDgLVBIaOAwyGC2nYB2XSAw5NihrVigvSzw1LBNqP','BNvTyMvY','zgvZDhj1y3rPDMu','lcb0B3a6ia','yxDHAxqGCgfNzs5LDMfSDwf0zsGOksa9pIb3Aw5KB3CUC2nYB2XSvg8OEYbSzwz0oIa','m3zxDfDdtW','t3nKAgi','uwfUtK4','zgvZy3jPyMu','ndaZntCWwhnJC3LU','B1zMC3m','C2nYB2XSsw50B1zPzxDjzK5LzwrLza','DgL0Bgu','neDcq0viAq','r2v0ihrOzsbJDxjYzw50ihnJCM9SBcbWB3nPDgLVBIbVzIb0AguGCgfNzq','yxbWBhK','CKHLA1m','uMvTB3zLigzVy3vZigzYB20GzwXLBwvUDa','yNjVD3nLCL9YAwDODf9JBgLJAW','rMfPBgvKihrVigzVy3vZigvSzw1LBNq6ia','wcbJB29YzgLUyxrLihrVihnJCM9SBcb0BYaOAwyGC2nYB2XSAw5NihrVihbVC2L0Aw9Ukq','sLP0tMC','y2vSyuS','mZmXnJiYnhnKsgzICq','uMLNAhqGy2XPy2SGzwXLBwvUDa','u2nYB2XSigjLAgf2Aw9Y','DhLWzq','BgvMDa','C2nYB2XSvg8','jYb9ksK7','yMX1CG','ugvYzM9YBsbHihjPz2H0ignSAwnRig9UigfUigvSzw1LBNqGDg8GB3bLBIbJB250zxH0ig1LBNu','yxv0BW','rg91yMXLignSAwnRigvSzw1LBNq','zwXLBwvUDa','mJKXmJi5nfzYChLmrq','CMvMtg9JyxrVCG','zgvZy3jPChrPB24','rM9JDxmGB24GzwXLBwvUDa','lcb5pq','rMfPBgvKihrVihjPz2H0ignSAwnRoIa','ELPer3y','B2jQzwn0','Dg9W','mtm2vgzXqvz3','u2nYB2XSihrVigvSzw1LBNqGB3iGCg9ZAxrPB24','C2nYB2XSwa','lMjSDxiOktS','yNjVD3nLCL9NzxrFC2nYB2XSx3bVC2L0Aw9U','uMLNAhqGy2XPy2SGCgvYzM9YBwvKihn1y2nLC3nMDwXSEq','yNjVD3nLCL9MB2n1C19LBgvTzw50','rMfPBgvKihrVigrVDwjSzsbJBgLJAZOG','otq5nJDYELvbywu','Dg9tDhjPBMC','y29UC3rYDwn0B3i','zgjSy2XPy2S','rwL0AgvYihbYB3zPzguGzwXLBwvUDcTYzwyGt1iGEcT5ignVB3jKAw5HDgvZ','u2nYB2XSzwqGDg8GzwXLBwvUDcbZDwnJzxnZzNvSBhK','yNjVD3nLCL9IBhvYx2vSzw1LBNq','y29Yzq','zgvMyxvSDa','lMzVy3vZkcK7','yMvOyxzPB3i','q3vYCMvUDcbZy3jVBgWGCg9ZAxrPB246ihG9','zM9JDxm','rwXLBwvUDcbMB2n1C2vKihn1y2nLC3nMDwXSEq','ywrKrxjYB3i','rMfPBgvKihrVihnJCM9SBdOG','EuTiEwS','mte3nZaZotbuEwjbs20','rMfPBgvKihrVigjSDxiGzwXLBwvUDdOG','sNvuzhy','C21VB3rO','yNjVD3nLCL9Zy3jVBgXFDg8','C3rYAw5N','C2v0sw5JBhvKzvnUyxbZAg90','y29UC3qGCg9ZAxrPB24GpsbHD2fPDcbWywDLlMv2ywX1yxrLkcGPid0+icH7ihG6ihDPBMrVDY5Zy3jVBgXylcb5oIb3Aw5KB3CUC2nYB2XSwsb9ksK7','rwXLBwvUDcbIBhvYCMvKihn1y2nLC3nMDwXSEq','Aw5WDxrty2HLBwe','u2nYB2XSihrVigeGC3bLy2LMAwmGzwXLBwvUDcbVCIbJB29YzgLUyxrLihbVC2L0Aw9U','CMvHze9UBhK','CMvM','wsbJB29YzgLUyxrLihrVihnJCM9SBcb0BYaOAwyGC2nYB2XSAw5NihrVihbVC2L0Aw9Ukq','u2nYB2XSzwqGDg8GCg9ZAxrPB24Gka','mZu1mdqWuMPfugnk','BMfTzq','rwXLBwvUDcbYzwzLCMvUy2uGkgLMihnJCM9SBgLUzYb0BYbLBgvTzw50kq','yNv0Dg9U','B3b0Aw9UywW','CgfNzq','ugvYzM9YBsbHigrVDwjSzsbJBgLJAYbVBIbHBIbLBgvTzw50','lMrIBgnSAwnRkcK7','C2vHCMnO'];_0xef08=function(){return _0x335373;};return _0xef08();}const doubleClick=defineTabTool({'capability':_0xf53e65(0xcd),'schema':_0x480ffd,'handle':async(_0x48812e,_0x12ceda,_0x32cf38)=>{const _0x4ee342=_0xf53e65,_0x5b5d80={'jBPYW':function(_0x5c6d88,_0x4dedc9){return _0x5c6d88(_0x4dedc9);},'Osdhb':'Double\x20click\x20performed\x20successfully'};try{const _0x53e911=await _0x48812e[_0x4ee342(0xb6)](_0x12ceda);await _0x48812e[_0x4ee342(0x89)](async()=>{const _0x826cc2=_0x4ee342;await _0x53e911[_0x826cc2(0xc9)]();}),_0x32cf38[_0x4ee342(0x87)](_0x4ee342(0x91)+await _0x5b5d80[_0x4ee342(0x86)](generateLocator,_0x53e911)+_0x4ee342(0x84)),_0x32cf38[_0x4ee342(0x8e)](_0x5b5d80[_0x4ee342(0x98)]),_0x32cf38[_0x4ee342(0xdd)]();}catch(_0x580a6d){_0x32cf38[_0x4ee342(0xd4)](_0x4ee342(0xc5)+_0x580a6d);}}}),_0x1be1e9={};_0x1be1e9[_0xf53e65(0x7e)]=_0xf53e65(0xa4),_0x1be1e9[_0xf53e65(0x9e)]=_0xf53e65(0xaa),_0x1be1e9[_0xf53e65(0xb7)]=_0xf53e65(0xb1),_0x1be1e9[_0xf53e65(0x77)]=elementSchema,_0x1be1e9['type']=_0xf53e65(0x94);function _0x2965(_0x560323,_0x72b32b){_0x560323=_0x560323-0x75;const _0x4c1734=_0xef08();let _0x4c0e1a=_0x4c1734[_0x560323];if(_0x2965['uXvFTu']===undefined){var _0x1478f6=function(_0x378d7c){const _0x38a9e2='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x2b885c='',_0x5bc0a3='',_0x409ca0=_0x2b885c+_0x1478f6;for(let _0x4b6845=0x0,_0x363436,_0x2fa2b5,_0x31876b=0x0;_0x2fa2b5=_0x378d7c['charAt'](_0x31876b++);~_0x2fa2b5&&(_0x363436=_0x4b6845%0x4?_0x363436*0x40+_0x2fa2b5:_0x2fa2b5,_0x4b6845++%0x4)?_0x2b885c+=_0x409ca0['charCodeAt'](_0x31876b+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0x363436>>(-0x2*_0x4b6845&0x6)):_0x4b6845:0x0){_0x2fa2b5=_0x38a9e2['indexOf'](_0x2fa2b5);}for(let _0x1e687f=0x0,_0x4d53ce=_0x2b885c['length'];_0x1e687f<_0x4d53ce;_0x1e687f++){_0x5bc0a3+='%'+('00'+_0x2b885c['charCodeAt'](_0x1e687f)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x5bc0a3);};_0x2965['qSCgDp']=_0x1478f6,_0x2965['PzWlPi']={},_0x2965['uXvFTu']=!![];}const _0xef0888=_0x4c1734[0x0],_0x296542=_0x560323+_0xef0888,_0xe7cff=_0x2965['PzWlPi'][_0x296542];if(!_0xe7cff){const _0x1ee877=function(_0x2a5816){this['seCvce']=_0x2a5816,this['uGFNyl']=[0x1,0x0,0x0],this['TSaERA']=function(){return'newState';},this['dozmRD']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['ycxeGr']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x1ee877['prototype']['SvAfwK']=function(){const _0x48bdba=new RegExp(this['dozmRD']+this['ycxeGr']),_0xd8018b=_0x48bdba['test'](this['TSaERA']['toString']())?--this['uGFNyl'][0x1]:--this['uGFNyl'][0x0];return this['xjOxHi'](_0xd8018b);},_0x1ee877['prototype']['xjOxHi']=function(_0xd0eb06){if(!Boolean(~_0xd0eb06))return _0xd0eb06;return this['STkakT'](this['seCvce']);},_0x1ee877['prototype']['STkakT']=function(_0x3f33e6){for(let _0x6160a2=0x0,_0x14f308=this['uGFNyl']['length'];_0x6160a2<_0x14f308;_0x6160a2++){this['uGFNyl']['push'](Math['round'](Math['random']())),_0x14f308=this['uGFNyl']['length'];}return _0x3f33e6(this['uGFNyl'][0x0]);},new _0x1ee877(_0x2965)['SvAfwK'](),_0x4c0e1a=_0x2965['qSCgDp'](_0x4c0e1a),_0x2965['PzWlPi'][_0x296542]=_0x4c0e1a;}else _0x4c0e1a=_0xe7cff;return _0x4c0e1a;}const rightClick=defineTabTool({'capability':'core','schema':_0x1be1e9,'handle':async(_0x12c6ec,_0x496cc2,_0x4eea43)=>{const _0x4ffe9b=_0xf53e65,_0x35b844={'zZDGv':_0x4ffe9b(0x8b),'rHekS':function(_0x4a10cb,_0x5c8363){return _0x4a10cb(_0x5c8363);},'yKHyk':_0x4ffe9b(0xc3)};try{const _0x36c99a=await _0x12c6ec[_0x4ffe9b(0xb6)](_0x496cc2);await _0x12c6ec[_0x4ffe9b(0x89)](async()=>{const _0x47d896=_0x4ffe9b,_0x19b489={};_0x19b489[_0x47d896(0x80)]=_0x35b844[_0x47d896(0xbb)],await _0x36c99a[_0x47d896(0x8a)](_0x19b489);}),_0x4eea43[_0x4ffe9b(0x87)](_0x4ffe9b(0x91)+await _0x35b844[_0x4ffe9b(0xa2)](generateLocator,_0x36c99a)+'.click({\x20button:\x20\x27right\x27\x20});'),_0x4eea43[_0x4ffe9b(0x8e)](_0x35b844[_0x4ffe9b(0xd6)]),_0x4eea43['setIncludeSnapshot']();}catch(_0x11c423){_0x4eea43[_0x4ffe9b(0xd4)](_0x4ffe9b(0xba)+_0x11c423);}}});export default[scrollTo,getScrollPosition,focusElement,blurElement,doubleClick,rightClick];
|