@weavetab/mcp 2.5.0-beta.5 → 2.5.1

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.
Files changed (160) hide show
  1. package/AGENTS.md +49 -49
  2. package/ARCHITECTURE.md +590 -590
  3. package/README.md +216 -100
  4. package/SECURITY.md +207 -207
  5. package/TROUBLESHOOTING.md +373 -365
  6. package/dist/anticaptcha/detector.js +395 -395
  7. package/dist/anticaptcha/solver.js +130 -130
  8. package/dist/cdp/bridge.js +73 -73
  9. package/dist/cdp/connector.js +46 -22
  10. package/dist/cdp/extension.js +34 -34
  11. package/dist/cdp/helpers.js +174 -174
  12. package/dist/cdp/pruner.js +195 -195
  13. package/dist/cdp/ref_cache.js +66 -66
  14. package/dist/cdp/security.js +10 -10
  15. package/dist/cdp/verify.js +57 -57
  16. package/dist/cdp/walker.js +563 -525
  17. package/dist/cli/plugin.js +26 -3
  18. package/dist/config/loader.d.ts +0 -3
  19. package/dist/config/loader.js +0 -9
  20. package/dist/index.js +0 -4
  21. package/dist/intelligence/intent.js +81 -81
  22. package/dist/intelligence/sessionMemory.js +2 -2
  23. package/dist/overlay/ghost.js +22 -22
  24. package/dist/overlay/injector.js +89 -89
  25. package/dist/plugin/extension_bridge.js +54 -54
  26. package/dist/plugin/interface.d.ts +7 -0
  27. package/dist/plugin/loader.js +3 -4
  28. package/dist/plugin/schema.d.ts +11 -0
  29. package/dist/plugin/schema.js +59 -0
  30. package/dist/security/guard.js +18 -18
  31. package/dist/sensors/actionability.js +167 -167
  32. package/dist/sensors/guard.js +29 -29
  33. package/dist/sensors/network.js +15 -17
  34. package/dist/server.d.ts +1 -1
  35. package/dist/server.js +173 -144
  36. package/dist/state/delta.js +6 -7
  37. package/dist/tools/automation.js +85 -85
  38. package/dist/tools/canvas.js +48 -25
  39. package/dist/tools/checkpoint.js +94 -35
  40. package/dist/tools/click.js +52 -41
  41. package/dist/tools/clipboard.js +80 -74
  42. package/dist/tools/design_extract.js +441 -441
  43. package/dist/tools/dialog.js +13 -13
  44. package/dist/tools/emulation.d.ts +2 -0
  45. package/dist/tools/emulation.js +7 -0
  46. package/dist/tools/fill.js +344 -347
  47. package/dist/tools/find.js +78 -52
  48. package/dist/tools/highlight.js +67 -67
  49. package/dist/tools/inspect.js +54 -25
  50. package/dist/tools/key.js +42 -35
  51. package/dist/tools/navigate.d.ts +1 -1
  52. package/dist/tools/navigate.js +35 -35
  53. package/dist/tools/office/parse.js +62 -18
  54. package/dist/tools/pdf.d.ts +9 -0
  55. package/dist/tools/pdf.js +7 -4
  56. package/dist/tools/performance.d.ts +11 -4
  57. package/dist/tools/performance.js +94 -42
  58. package/dist/tools/performance_test.d.ts +2 -2
  59. package/dist/tools/performance_test.js +69 -69
  60. package/dist/tools/pointer.js +116 -116
  61. package/dist/tools/read.js +99 -67
  62. package/dist/tools/recording.js +9 -0
  63. package/dist/tools/scrape.js +146 -146
  64. package/dist/tools/screenshot.d.ts +2 -0
  65. package/dist/tools/screenshot.js +46 -4
  66. package/dist/tools/scroll.d.ts +3 -1
  67. package/dist/tools/scroll.js +13 -15
  68. package/dist/tools/select.d.ts +3 -0
  69. package/dist/tools/select.js +131 -124
  70. package/dist/tools/snapshot.js +8 -6
  71. package/dist/tools/storage.d.ts +5 -1
  72. package/dist/tools/storage.js +16 -0
  73. package/dist/tools/tabs.d.ts +7 -5
  74. package/dist/tools/tabs.js +79 -26
  75. package/dist/tools/thought.js +8 -8
  76. package/dist/tools/type.js +274 -274
  77. package/dist/tools/type_secret.js +23 -23
  78. package/dist/tools/upload.js +3 -3
  79. package/dist/tools/video_compiler.js +9 -0
  80. package/dist/tools/wait.js +35 -35
  81. package/dist/version.d.ts +1 -1
  82. package/dist/version.js +1 -1
  83. package/docs/DOCUMENTATION.md +583 -585
  84. package/docs/PLUGINS.md +139 -121
  85. package/docs/TOOLS.md +3 -4
  86. package/docs/architecture/blind-injection.md +83 -83
  87. package/docs/architecture/overview.md +49 -49
  88. package/docs/configuration/configuration.md +39 -27
  89. package/docs/configuration/folders.md +62 -55
  90. package/docs/desktop-automation/electron-apps.md +225 -214
  91. package/docs/get-started/installation.md +1 -1
  92. package/docs/get-started/introduction.md +60 -60
  93. package/docs/get-started/quickstart.md +2 -2
  94. package/docs/get-started/setup-wizard.md +1 -1
  95. package/docs/intelligence/site-profiles.md +151 -151
  96. package/docs/tools/tools.md +582 -631
  97. package/docs/troubleshooting/trouble-loop.md +31 -31
  98. package/ext-dist/background.js +415 -415
  99. package/ext-dist/content.js +2527 -2527
  100. package/ext-dist/dashboard.html +583 -583
  101. package/ext-dist/hud/hud.js +3 -3
  102. package/ext-dist/hud/index.html +20 -20
  103. package/ext-dist/manifest.json +73 -73
  104. package/ext-dist/styles.css +223 -223
  105. package/mcp.json +796 -805
  106. package/package.json +8 -8
  107. package/server.json +23 -23
  108. package/smithery.yaml +7 -11
  109. package/dist/cdp/walker.test.d.ts +0 -2
  110. package/dist/cdp/walker.test.js +0 -172
  111. package/dist/intelligence/sessionMemory.test.d.ts +0 -2
  112. package/dist/intelligence/sessionMemory.test.js +0 -62
  113. package/dist/intelligence/trail.test.d.ts +0 -2
  114. package/dist/intelligence/trail.test.js +0 -110
  115. package/dist/state/cache.test.d.ts +0 -2
  116. package/dist/state/cache.test.js +0 -76
  117. package/dist/state/delta.test.d.ts +0 -2
  118. package/dist/state/delta.test.js +0 -279
  119. package/dist/state/groups.d.ts +0 -15
  120. package/dist/state/groups.js +0 -80
  121. package/dist/tools/accessibility.d.ts +0 -14
  122. package/dist/tools/accessibility.js +0 -32
  123. package/dist/tools/ask.d.ts +0 -14
  124. package/dist/tools/ask.js +0 -49
  125. package/dist/tools/click_and_wait.d.ts +0 -33
  126. package/dist/tools/click_and_wait.js +0 -149
  127. package/dist/tools/drag.d.ts +0 -15
  128. package/dist/tools/drag.js +0 -29
  129. package/dist/tools/geo.d.ts +0 -19
  130. package/dist/tools/geo.js +0 -29
  131. package/dist/tools/github/analyze.d.ts +0 -4
  132. package/dist/tools/github/analyze.js +0 -113
  133. package/dist/tools/github/cache.d.ts +0 -21
  134. package/dist/tools/github/cache.js +0 -28
  135. package/dist/tools/github/index.d.ts +0 -19
  136. package/dist/tools/github/index.js +0 -40
  137. package/dist/tools/github/issues.d.ts +0 -9
  138. package/dist/tools/github/issues.js +0 -88
  139. package/dist/tools/github/pr.d.ts +0 -5
  140. package/dist/tools/github/pr.js +0 -88
  141. package/dist/tools/github/rateLimiter.d.ts +0 -4
  142. package/dist/tools/github/rateLimiter.js +0 -46
  143. package/dist/tools/github/read.d.ts +0 -34
  144. package/dist/tools/github/read.js +0 -74
  145. package/dist/tools/github/repoContext.d.ts +0 -20
  146. package/dist/tools/github/repoContext.js +0 -129
  147. package/dist/tools/hover.d.ts +0 -19
  148. package/dist/tools/hover.js +0 -57
  149. package/dist/tools/integration.test.d.ts +0 -2
  150. package/dist/tools/integration.test.js +0 -96
  151. package/dist/tools/macro_compiler.d.ts +0 -7
  152. package/dist/tools/macro_compiler.js +0 -82
  153. package/dist/tools/mouse.d.ts +0 -21
  154. package/dist/tools/mouse.js +0 -62
  155. package/dist/tools/response.d.ts +0 -129
  156. package/dist/tools/response.js +0 -5
  157. package/dist/tools/wait_for.d.ts +0 -23
  158. package/dist/tools/wait_for.js +0 -30
  159. package/dist/tools/windows.d.ts +0 -22
  160. package/dist/tools/windows.js +0 -57
@@ -6,12 +6,12 @@
6
6
  export async function isExtensionLoaded(session) {
7
7
  try {
8
8
  const { result } = await session.Runtime.evaluate({
9
- expression: `!!(
10
- document.getElementById('wt-extension-marker') ||
11
- document.querySelector('weavetab-host') ||
12
- document.querySelector('[data-wt-internal]') ||
13
- document.getElementById('__Weavetab_cursor_host') ||
14
- document.getElementById('wt-ui-styles')
9
+ expression: `!!(
10
+ document.getElementById('wt-extension-marker') ||
11
+ document.querySelector('weavetab-host') ||
12
+ document.querySelector('[data-wt-internal]') ||
13
+ document.getElementById('__Weavetab_cursor_host') ||
14
+ document.getElementById('wt-ui-styles')
15
15
  )`,
16
16
  returnByValue: true,
17
17
  });
@@ -50,15 +50,15 @@ export async function extensionHealth(session) {
50
50
  // Use DOM markers + fallback JS checks via postMessage bridge
51
51
  const loaded = await isExtensionLoaded(session);
52
52
  const { result } = await session.Runtime.evaluate({
53
- expression: `(function() {
54
- const features = [];
55
- if (document.querySelector('weavetab-host') || document.getElementById('__Weavetab_cursor_host')) features.push('cursor');
56
- if (document.querySelector('[data-wt-internal]') || document.getElementById('wt-ui-styles')) features.push('styles');
57
- if (document.querySelector('.wt-bubble')) features.push('bubble');
58
- return JSON.stringify({
59
- loaded: ${loaded},
60
- features
61
- });
53
+ expression: `(function() {
54
+ const features = [];
55
+ if (document.querySelector('weavetab-host') || document.getElementById('__Weavetab_cursor_host')) features.push('cursor');
56
+ if (document.querySelector('[data-wt-internal]') || document.getElementById('wt-ui-styles')) features.push('styles');
57
+ if (document.querySelector('.wt-bubble')) features.push('bubble');
58
+ return JSON.stringify({
59
+ loaded: ${loaded},
60
+ features
61
+ });
62
62
  })()`,
63
63
  returnByValue: true,
64
64
  });
@@ -77,17 +77,17 @@ export async function extensionHealth(session) {
77
77
  export async function suppressOverlays(session) {
78
78
  try {
79
79
  await session.Runtime.evaluate({
80
- expression: `(function() {
81
- // Remove any existing Weavetab overlay elements
82
- document.querySelectorAll('[data-Weavetab-overlay]').forEach(el => el.remove());
83
- // Hide fallback visual elements
84
- var sr = document.getElementById('Weavetab-root');
85
- if (sr && sr.shadowRoot) {
86
- var els = sr.shadowRoot.querySelectorAll('#wt-fallback-cursor, #wt-fallback-hud, #wt-fallback-thought');
87
- els.forEach(function(el){ el.style.display = 'none'; });
88
- }
89
- // Post a message for the content script (isolated world)
90
- window.postMessage({ type: 'Weavetab_SUPPRESS_VISUALS', suppress: true }, '*');
80
+ expression: `(function() {
81
+ // Remove any existing Weavetab overlay elements
82
+ document.querySelectorAll('[data-Weavetab-overlay]').forEach(el => el.remove());
83
+ // Hide fallback visual elements
84
+ var sr = document.getElementById('Weavetab-root');
85
+ if (sr && sr.shadowRoot) {
86
+ var els = sr.shadowRoot.querySelectorAll('#wt-fallback-cursor, #wt-fallback-hud, #wt-fallback-thought');
87
+ els.forEach(function(el){ el.style.display = 'none'; });
88
+ }
89
+ // Post a message for the content script (isolated world)
90
+ window.postMessage({ type: 'Weavetab_SUPPRESS_VISUALS', suppress: true }, '*');
91
91
  })()`,
92
92
  returnByValue: false,
93
93
  });
@@ -101,14 +101,14 @@ export async function suppressOverlays(session) {
101
101
  export async function restoreOverlays(session) {
102
102
  try {
103
103
  await session.Runtime.evaluate({
104
- expression: `(function() {
105
- // Restore fallback visual elements
106
- var sr = document.getElementById('Weavetab-root');
107
- if (sr && sr.shadowRoot) {
108
- var els = sr.shadowRoot.querySelectorAll('#wt-fallback-cursor, #wt-fallback-hud, #wt-fallback-thought');
109
- els.forEach(function(el){ el.style.display = ''; });
110
- }
111
- window.postMessage({ type: 'Weavetab_SUPPRESS_VISUALS', suppress: false }, '*');
104
+ expression: `(function() {
105
+ // Restore fallback visual elements
106
+ var sr = document.getElementById('Weavetab-root');
107
+ if (sr && sr.shadowRoot) {
108
+ var els = sr.shadowRoot.querySelectorAll('#wt-fallback-cursor, #wt-fallback-hud, #wt-fallback-thought');
109
+ els.forEach(function(el){ el.style.display = ''; });
110
+ }
111
+ window.postMessage({ type: 'Weavetab_SUPPRESS_VISUALS', suppress: false }, '*');
112
112
  })()`,
113
113
  returnByValue: false,
114
114
  });
@@ -20,10 +20,10 @@ async function drainQueue(session, targetId) {
20
20
  try {
21
21
  const msgData = JSON.stringify(messages.length === 1 ? messages[0] : messages);
22
22
  await session.Runtime.evaluate({
23
- expression: `
24
- try {
25
- window.postMessage({ type: 'Weavetab-msg-in', data: ${msgData} }, '*');
26
- } catch(e) {}
23
+ expression: `
24
+ try {
25
+ window.postMessage({ type: 'Weavetab-msg-in', data: ${msgData} }, '*');
26
+ } catch(e) {}
27
27
  `
28
28
  });
29
29
  batch.forEach(q => q.resolve(true));
@@ -107,26 +107,26 @@ export async function getFromExtension(session, message, retries = 0) {
107
107
  for (let attempt = 0; attempt <= retries; attempt++) {
108
108
  try {
109
109
  const { result } = await session.Runtime.evaluate({
110
- expression: `new Promise((resolve) => {
111
- try {
112
- const id = Math.random().toString();
113
- const listener = (e) => {
114
- if (e.detail && e.detail.id === id) {
115
- window.removeEventListener('Weavetab-msg-out', listener);
116
- resolve(JSON.stringify(e.detail.data));
117
- }
118
- };
119
- window.addEventListener('Weavetab-msg-out', listener);
120
- window.dispatchEvent(new CustomEvent('Weavetab-msg-in', { detail: Object.assign({}, ${JSON.stringify(message)}, { id }) }));
121
-
122
- // Fallback timeout — 100ms fail-fast (reduced from 150ms)
123
- setTimeout(() => {
124
- window.removeEventListener('Weavetab-msg-out', listener);
125
- resolve("null");
126
- }, 100);
127
- } catch (e) {
128
- resolve("null");
129
- }
110
+ expression: `new Promise((resolve) => {
111
+ try {
112
+ const id = Math.random().toString();
113
+ const listener = (e) => {
114
+ if (e.detail && e.detail.id === id) {
115
+ window.removeEventListener('Weavetab-msg-out', listener);
116
+ resolve(JSON.stringify(e.detail.data));
117
+ }
118
+ };
119
+ window.addEventListener('Weavetab-msg-out', listener);
120
+ window.dispatchEvent(new CustomEvent('Weavetab-msg-in', { detail: Object.assign({}, ${JSON.stringify(message)}, { id }) }));
121
+
122
+ // Fallback timeout — 100ms fail-fast (reduced from 150ms)
123
+ setTimeout(() => {
124
+ window.removeEventListener('Weavetab-msg-out', listener);
125
+ resolve("null");
126
+ }, 100);
127
+ } catch (e) {
128
+ resolve("null");
129
+ }
130
130
  })`,
131
131
  awaitPromise: true,
132
132
  returnByValue: true
@@ -152,86 +152,86 @@ export async function getFromExtension(session, message, retries = 0) {
152
152
  }
153
153
  export async function hideWeaveTabOverlay(session) {
154
154
  await session.Runtime.evaluate({
155
- expression: `(function(){
156
- var existing = document.getElementById('__wt_hide_overlay_styles');
157
- if (existing) return; // already hidden
158
- var style = document.createElement('style');
159
- style.id = '__wt_hide_overlay_styles';
160
- // Cover ALL Weavetab overlay elements so they never appear in screenshots/PDFs/snapshots:
161
- // - [id^="Weavetab-"] : Weavetab-root shadow host, any legacy Weavetab- elements
162
- // - [id^="__Weavetab_"] : __Weavetab_cursor_host (ghost cursor)
163
- // - [id^="wt-"] : wt-* legacy element IDs
164
- // - [data-wt-internal] : HUD iframe host (closed shadow DOM mount)
165
- // - [data-wt-ignore] : any element flagged as agent-invisible
166
- // - .wt-bubble : thought bubble / action text popups
167
- // - #__wt_ask_bridge : question input bridge element
168
- // - #wt-debug-overlay : debug overlay panel
169
- // - #wt-main-container : WeaveTab OS panel (todos + chat)
170
- style.textContent = [
171
- '[id^="Weavetab-"]',
172
- '[id^="__Weavetab_"]',
173
- '[id^="wt-"]',
174
- '[data-wt-internal]',
175
- '[data-wt-ignore]',
176
- '.wt-bubble',
177
- '#__wt_ask_bridge',
178
- '#wt-debug-overlay',
179
- '#wt-main-container',
180
- ].join(', ') + ' { display: none !important; visibility: hidden !important; opacity: 0 !important; }';
181
- document.head.appendChild(style);
155
+ expression: `(function(){
156
+ var existing = document.getElementById('__wt_hide_overlay_styles');
157
+ if (existing) return; // already hidden
158
+ var style = document.createElement('style');
159
+ style.id = '__wt_hide_overlay_styles';
160
+ // Cover ALL Weavetab overlay elements so they never appear in screenshots/PDFs/snapshots:
161
+ // - [id^="Weavetab-"] : Weavetab-root shadow host, any legacy Weavetab- elements
162
+ // - [id^="__Weavetab_"] : __Weavetab_cursor_host (ghost cursor)
163
+ // - [id^="wt-"] : wt-* legacy element IDs
164
+ // - [data-wt-internal] : HUD iframe host (closed shadow DOM mount)
165
+ // - [data-wt-ignore] : any element flagged as agent-invisible
166
+ // - .wt-bubble : thought bubble / action text popups
167
+ // - #__wt_ask_bridge : question input bridge element
168
+ // - #wt-debug-overlay : debug overlay panel
169
+ // - #wt-main-container : WeaveTab OS panel (todos + chat)
170
+ style.textContent = [
171
+ '[id^="Weavetab-"]',
172
+ '[id^="__Weavetab_"]',
173
+ '[id^="wt-"]',
174
+ '[data-wt-internal]',
175
+ '[data-wt-ignore]',
176
+ '.wt-bubble',
177
+ '#__wt_ask_bridge',
178
+ '#wt-debug-overlay',
179
+ '#wt-main-container',
180
+ ].join(', ') + ' { display: none !important; visibility: hidden !important; opacity: 0 !important; }';
181
+ document.head.appendChild(style);
182
182
  })()`,
183
183
  returnByValue: false,
184
184
  }).catch(() => { });
185
185
  }
186
186
  export async function restoreWeaveTabOverlay(session) {
187
187
  await session.Runtime.evaluate({
188
- expression: `(function(){
189
- var style = document.getElementById('__wt_hide_overlay_styles');
190
- if (style) style.remove();
188
+ expression: `(function(){
189
+ var style = document.getElementById('__wt_hide_overlay_styles');
190
+ if (style) style.remove();
191
191
  })()`,
192
192
  returnByValue: false,
193
193
  }).catch(() => { });
194
194
  }
195
195
  // ─── Secret Hardening & Containment Helpers ──────────────────────────────────
196
196
  export async function applySecretHardening(session, objectId, selector) {
197
- const hardeningScript = `function() {
198
- try {
199
- const el = this;
200
- if (!el) return;
201
- // Mark as secret
202
- try { el.setAttribute('data-wt-secret', 'true'); } catch (_) {}
203
-
204
- // 1. Redact direct .value access via instance-level property override
205
- const proto = Object.getPrototypeOf(el);
206
- const origDesc = proto ? Object.getOwnPropertyDescriptor(proto, 'value') : null;
207
- if (origDesc) {
208
- Object.defineProperty(el, 'value', {
209
- get: function() { return '[REDACTED]'; },
210
- set: origDesc.set,
211
- configurable: true,
212
- enumerable: true
213
- });
214
- }
215
-
216
- // 2. Defeat array spread, iteration, and coercion
217
- try {
218
- Object.defineProperty(el, Symbol.iterator, {
219
- value: function* () { yield '[REDACTED]'; },
220
- configurable: true
221
- });
222
- Object.defineProperty(el, Symbol.toPrimitive, {
223
- value: function() { return '[REDACTED]'; },
224
- configurable: true
225
- });
226
- // Defeat JSON.stringify / structuredClone leaks
227
- Object.defineProperty(el, 'toJSON', {
228
- value: function() { return '[REDACTED]'; },
229
- configurable: true
230
- });
231
- } catch(_) {}
232
- } catch (e) {
233
- // fail silently so as not to disrupt the page execution
234
- }
197
+ const hardeningScript = `function() {
198
+ try {
199
+ const el = this;
200
+ if (!el) return;
201
+ // Mark as secret
202
+ try { el.setAttribute('data-wt-secret', 'true'); } catch (_) {}
203
+
204
+ // 1. Redact direct .value access via instance-level property override
205
+ const proto = Object.getPrototypeOf(el);
206
+ const origDesc = proto ? Object.getOwnPropertyDescriptor(proto, 'value') : null;
207
+ if (origDesc) {
208
+ Object.defineProperty(el, 'value', {
209
+ get: function() { return '[REDACTED]'; },
210
+ set: origDesc.set,
211
+ configurable: true,
212
+ enumerable: true
213
+ });
214
+ }
215
+
216
+ // 2. Defeat array spread, iteration, and coercion
217
+ try {
218
+ Object.defineProperty(el, Symbol.iterator, {
219
+ value: function* () { yield '[REDACTED]'; },
220
+ configurable: true
221
+ });
222
+ Object.defineProperty(el, Symbol.toPrimitive, {
223
+ value: function() { return '[REDACTED]'; },
224
+ configurable: true
225
+ });
226
+ // Defeat JSON.stringify / structuredClone leaks
227
+ Object.defineProperty(el, 'toJSON', {
228
+ value: function() { return '[REDACTED]'; },
229
+ configurable: true
230
+ });
231
+ } catch(_) {}
232
+ } catch (e) {
233
+ // fail silently so as not to disrupt the page execution
234
+ }
235
235
  }`;
236
236
  if (objectId) {
237
237
  await session.Runtime.callFunctionOn({
@@ -242,11 +242,11 @@ export async function applySecretHardening(session, objectId, selector) {
242
242
  }
243
243
  else if (selector) {
244
244
  await session.Runtime.evaluate({
245
- expression: `(function(sel) {
246
- const el = document.querySelector(sel) || (window.__Weavetab_shadowQuery ? window.__Weavetab_shadowQuery(sel) : null);
247
- if (el) {
248
- (${hardeningScript}).call(el);
249
- }
245
+ expression: `(function(sel) {
246
+ const el = document.querySelector(sel) || (window.__Weavetab_shadowQuery ? window.__Weavetab_shadowQuery(sel) : null);
247
+ if (el) {
248
+ (${hardeningScript}).call(el);
249
+ }
250
250
  })(${JSON.stringify(selector)})`,
251
251
  returnByValue: false
252
252
  }).catch(() => { });
@@ -260,8 +260,8 @@ export async function registerAndHardenSecretField(session, targetId, selector,
260
260
  let resolvedObjectId = objectId;
261
261
  if (!resolvedObjectId && selector) {
262
262
  const nodeInfo = await session.Runtime.evaluate({
263
- expression: `(function(sel) {
264
- return document.querySelector(sel) || (window.__Weavetab_shadowQuery ? window.__Weavetab_shadowQuery(sel) : null);
263
+ expression: `(function(sel) {
264
+ return document.querySelector(sel) || (window.__Weavetab_shadowQuery ? window.__Weavetab_shadowQuery(sel) : null);
265
265
  })(${JSON.stringify(selector)})`,
266
266
  returnByValue: false
267
267
  }).catch(() => null);
@@ -287,87 +287,87 @@ export async function registerAndHardenSecretField(session, targetId, selector,
287
287
  }
288
288
  export async function maskSecretFieldsForCapture(session) {
289
289
  await session.Runtime.evaluate({
290
- expression: `(function() {
291
- var secretRegex = /password|passcode|pin|passphrase|secret|token|auth.?key|access.?code|mot.?de.?passe|contrase[nñ]a|kennwort|senha/i;
292
-
293
- function queryAllDeep(root, matchFn) {
294
- var matched = [];
295
- var elements = root.querySelectorAll('*');
296
- for (var i = 0; i < elements.length; i++) {
297
- var el = elements[i];
298
- if (matchFn(el)) matched.push(el);
299
- if (el.shadowRoot) {
300
- matched = matched.concat(queryAllDeep(el.shadowRoot, matchFn));
301
- }
302
- }
303
- return matched;
304
- }
305
-
306
- function isSecretNode(el) {
307
- if (!el || !el.tagName) return false;
308
- if (el.hasAttribute && el.hasAttribute('data-wt-secret')) return true;
309
- var tag = el.tagName.toLowerCase();
310
- if (tag === 'input' || tag === 'textarea') {
311
- var t = (el.getAttribute('type') || '').toLowerCase();
312
- var ac = (el.getAttribute('autocomplete') || '').toLowerCase();
313
- var name = (el.getAttribute('name') || '').toLowerCase();
314
- var id = (el.getAttribute('id') || '').toLowerCase();
315
- var aria = (el.getAttribute('aria-label') || '').toLowerCase();
316
- return t === 'password' || ac.includes('password') || secretRegex.test(name) || secretRegex.test(id) || secretRegex.test(aria);
317
- }
318
- return false;
319
- }
320
-
321
- var els = queryAllDeep(document, isSecretNode);
322
- for (var i = 0; i < els.length; i++) {
323
- var el = els[i];
324
- el.__wt_cap_val_backup = el.value;
325
- try { el.value = ''; } catch(e) {}
326
- if (el.isContentEditable) {
327
- el.__wt_cap_txt_backup = el.textContent;
328
- try { el.textContent = ''; } catch(e) {}
329
- }
330
- el.__wt_cap_sec_backup = el.style.webkitTextSecurity;
331
- try { el.style.webkitTextSecurity = 'disc'; } catch(e) {}
332
- }
290
+ expression: `(function() {
291
+ var secretRegex = /password|passcode|pin|passphrase|secret|token|auth.?key|access.?code|mot.?de.?passe|contrase[nñ]a|kennwort|senha/i;
292
+
293
+ function queryAllDeep(root, matchFn) {
294
+ var matched = [];
295
+ var elements = root.querySelectorAll('*');
296
+ for (var i = 0; i < elements.length; i++) {
297
+ var el = elements[i];
298
+ if (matchFn(el)) matched.push(el);
299
+ if (el.shadowRoot) {
300
+ matched = matched.concat(queryAllDeep(el.shadowRoot, matchFn));
301
+ }
302
+ }
303
+ return matched;
304
+ }
305
+
306
+ function isSecretNode(el) {
307
+ if (!el || !el.tagName) return false;
308
+ if (el.hasAttribute && el.hasAttribute('data-wt-secret')) return true;
309
+ var tag = el.tagName.toLowerCase();
310
+ if (tag === 'input' || tag === 'textarea') {
311
+ var t = (el.getAttribute('type') || '').toLowerCase();
312
+ var ac = (el.getAttribute('autocomplete') || '').toLowerCase();
313
+ var name = (el.getAttribute('name') || '').toLowerCase();
314
+ var id = (el.getAttribute('id') || '').toLowerCase();
315
+ var aria = (el.getAttribute('aria-label') || '').toLowerCase();
316
+ return t === 'password' || ac.includes('password') || secretRegex.test(name) || secretRegex.test(id) || secretRegex.test(aria);
317
+ }
318
+ return false;
319
+ }
320
+
321
+ var els = queryAllDeep(document, isSecretNode);
322
+ for (var i = 0; i < els.length; i++) {
323
+ var el = els[i];
324
+ el.__wt_cap_val_backup = el.value;
325
+ try { el.value = ''; } catch(e) {}
326
+ if (el.isContentEditable) {
327
+ el.__wt_cap_txt_backup = el.textContent;
328
+ try { el.textContent = ''; } catch(e) {}
329
+ }
330
+ el.__wt_cap_sec_backup = el.style.webkitTextSecurity;
331
+ try { el.style.webkitTextSecurity = 'disc'; } catch(e) {}
332
+ }
333
333
  })()`,
334
334
  returnByValue: false,
335
335
  }).catch(() => { });
336
336
  }
337
337
  export async function restoreSecretFieldsAfterCapture(session) {
338
338
  await session.Runtime.evaluate({
339
- expression: `(function() {
340
- function queryAllDeep(root) {
341
- var matched = [];
342
- var elements = root.querySelectorAll('*');
343
- for (var i = 0; i < elements.length; i++) {
344
- var el = elements[i];
345
- if (el.__wt_cap_val_backup !== undefined || el.__wt_cap_txt_backup !== undefined || el.__wt_cap_sec_backup !== undefined) {
346
- matched.push(el);
347
- }
348
- if (el.shadowRoot) {
349
- matched = matched.concat(queryAllDeep(el.shadowRoot));
350
- }
351
- }
352
- return matched;
353
- }
354
-
355
- var els = queryAllDeep(document);
356
- for (var i = 0; i < els.length; i++) {
357
- var el = els[i];
358
- if (el.__wt_cap_val_backup !== undefined) {
359
- try { el.value = el.__wt_cap_val_backup; } catch(e) {}
360
- delete el.__wt_cap_val_backup;
361
- }
362
- if (el.__wt_cap_txt_backup !== undefined) {
363
- try { el.textContent = el.__wt_cap_txt_backup; } catch(e) {}
364
- delete el.__wt_cap_txt_backup;
365
- }
366
- if (el.__wt_cap_sec_backup !== undefined) {
367
- try { el.style.webkitTextSecurity = el.__wt_cap_sec_backup; } catch(e) {}
368
- delete el.__wt_cap_sec_backup;
369
- }
370
- }
339
+ expression: `(function() {
340
+ function queryAllDeep(root) {
341
+ var matched = [];
342
+ var elements = root.querySelectorAll('*');
343
+ for (var i = 0; i < elements.length; i++) {
344
+ var el = elements[i];
345
+ if (el.__wt_cap_val_backup !== undefined || el.__wt_cap_txt_backup !== undefined || el.__wt_cap_sec_backup !== undefined) {
346
+ matched.push(el);
347
+ }
348
+ if (el.shadowRoot) {
349
+ matched = matched.concat(queryAllDeep(el.shadowRoot));
350
+ }
351
+ }
352
+ return matched;
353
+ }
354
+
355
+ var els = queryAllDeep(document);
356
+ for (var i = 0; i < els.length; i++) {
357
+ var el = els[i];
358
+ if (el.__wt_cap_val_backup !== undefined) {
359
+ try { el.value = el.__wt_cap_val_backup; } catch(e) {}
360
+ delete el.__wt_cap_val_backup;
361
+ }
362
+ if (el.__wt_cap_txt_backup !== undefined) {
363
+ try { el.textContent = el.__wt_cap_txt_backup; } catch(e) {}
364
+ delete el.__wt_cap_txt_backup;
365
+ }
366
+ if (el.__wt_cap_sec_backup !== undefined) {
367
+ try { el.style.webkitTextSecurity = el.__wt_cap_sec_backup; } catch(e) {}
368
+ delete el.__wt_cap_sec_backup;
369
+ }
370
+ }
371
371
  })()`,
372
372
  returnByValue: false,
373
373
  }).catch(() => { });