@wordbricks/playwright-mcp 0.1.13 → 0.1.15

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.
@@ -33,6 +33,37 @@ async function applyInitScript(browserContext, config) {
33
33
  await browserContext.addInitScript(scriptContent);
34
34
  }
35
35
  }
36
+ async function hidePlaywrightMarkers(browserContext) {
37
+ await browserContext.addInitScript(() => {
38
+ // Delete the property if it exists
39
+ delete window.__pwInitScripts;
40
+ // Redefine `Object.getOwnPropertyNames`
41
+ const originalGetOwnPropertyNames = Object.getOwnPropertyNames;
42
+ Object.getOwnPropertyNames = (obj) => {
43
+ const props = originalGetOwnPropertyNames(obj);
44
+ return props.filter((prop) => prop !== '__pwInitScripts');
45
+ };
46
+ // Use a Proxy to handle access to `window`
47
+ const windowHandler = {
48
+ get(target, prop) {
49
+ if (prop === '__pwInitScripts')
50
+ return undefined; // Hide the property
51
+ return Reflect.get(target, prop);
52
+ },
53
+ has(target, prop) {
54
+ if (prop === '__pwInitScripts')
55
+ return false; // Prevent detection via "in" operator
56
+ return Reflect.has(target, prop);
57
+ },
58
+ };
59
+ const proxiedWindow = new Proxy(window, windowHandler);
60
+ Object.defineProperty(globalThis, 'window', {
61
+ value: proxiedWindow,
62
+ configurable: false,
63
+ writable: false,
64
+ });
65
+ });
66
+ }
36
67
  export function contextFactory(config) {
37
68
  if (config.browser.remoteEndpoint)
38
69
  return new RemoteContextFactory(config);
@@ -146,35 +177,7 @@ class IsolatedContextFactory extends BaseContextFactory {
146
177
  async _doCreateContext(browser) {
147
178
  const browserContext = await browser.newContext(this.config.browser.contextOptions);
148
179
  await applyInitScript(browserContext, this.config);
149
- await browserContext.addInitScript(() => {
150
- // Delete the property if it exists
151
- delete window.__pwInitScripts;
152
- // Redefine `Object.getOwnPropertyNames`
153
- const originalGetOwnPropertyNames = Object.getOwnPropertyNames;
154
- Object.getOwnPropertyNames = (obj) => {
155
- const props = originalGetOwnPropertyNames(obj);
156
- return props.filter((prop) => prop !== '__pwInitScripts');
157
- };
158
- // Use a Proxy to handle access to `window`
159
- const windowHandler = {
160
- get(target, prop) {
161
- if (prop === '__pwInitScripts')
162
- return undefined; // Hide the property
163
- return Reflect.get(target, prop);
164
- },
165
- has(target, prop) {
166
- if (prop === '__pwInitScripts')
167
- return false; // Prevent detection via "in" operator
168
- return Reflect.has(target, prop);
169
- },
170
- };
171
- const proxiedWindow = new Proxy(window, windowHandler);
172
- Object.defineProperty(globalThis, 'window', {
173
- value: proxiedWindow,
174
- configurable: false,
175
- writable: false,
176
- });
177
- });
180
+ await hidePlaywrightMarkers(browserContext);
178
181
  return browserContext;
179
182
  }
180
183
  }
@@ -188,6 +191,7 @@ class CdpContextFactory extends BaseContextFactory {
188
191
  async _doCreateContext(browser) {
189
192
  const browserContext = this.config.browser.isolated ? await browser.newContext() : browser.contexts()[0];
190
193
  await applyInitScript(browserContext, this.config);
194
+ await hidePlaywrightMarkers(browserContext);
191
195
  return browserContext;
192
196
  }
193
197
  }
@@ -205,6 +209,7 @@ class RemoteContextFactory extends BaseContextFactory {
205
209
  async _doCreateContext(browser) {
206
210
  const browserContext = await browser.newContext();
207
211
  await applyInitScript(browserContext, this.config);
212
+ await hidePlaywrightMarkers(browserContext);
208
213
  return browserContext;
209
214
  }
210
215
  }
@@ -241,6 +246,7 @@ class PersistentContextFactory {
241
246
  args,
242
247
  });
243
248
  await applyInitScript(browserContext, this.config);
249
+ await hidePlaywrightMarkers(browserContext);
244
250
  // Start auto-close timer
245
251
  this._startAutoCloseTimer(browserContext);
246
252
  const close = () => this._closeBrowserContext(browserContext, userDataDir);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordbricks/playwright-mcp",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "Playwright Tools for MCP",
5
5
  "type": "module",
6
6
  "repository": {
@@ -60,7 +60,7 @@
60
60
  "lodash": "^4.17.21",
61
61
  "mime": "^4.0.7",
62
62
  "ms": "^2.1.3",
63
- "playwright-core": "npm:rebrowser-playwright-core@1.52.0",
63
+ "playwright-core": "1.56.1",
64
64
  "raw-body": "^3.0.0",
65
65
  "typescript-parsec": "0.3.4",
66
66
  "ws": "^8.18.1",
@@ -95,5 +95,8 @@
95
95
  },
96
96
  "bin": {
97
97
  "mcp-server-playwright": "cli-wrapper.js"
98
+ },
99
+ "patchedDependencies": {
100
+ "playwright-core@1.56.1": "patches/playwright-core@1.56.1.patch"
98
101
  }
99
102
  }