@ogulcancelik/pi-web-browse 1.0.1 → 1.0.3

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/README.md CHANGED
@@ -51,7 +51,7 @@ Environment variables (all optional):
51
51
  | `WEB_BROWSE_BROWSER_BIN` | Browser binary path | Auto-detected |
52
52
  | `WEB_BROWSE_USER_AGENT` | User-Agent string | Chrome on Windows |
53
53
  | `WEB_BROWSE_DAEMON_PORT` | Daemon HTTP port | 9377 |
54
- | `WEB_BROWSE_CDP_PORT` | Chrome DevTools port | 9223 |
54
+ | `WEB_BROWSE_CDP_PORT` | Chrome DevTools port | 9225 |
55
55
  | `WEB_BROWSE_DEBUG_DUMP` | Save debug files on failure | off |
56
56
 
57
57
  ## Browser Detection
package/SKILL.md CHANGED
@@ -31,7 +31,7 @@ Environment variables:
31
31
  | `WEB_BROWSE_BROWSER_BIN` | Path to browser binary (auto-detected if not set) |
32
32
  | `WEB_BROWSE_USER_AGENT` | Override User-Agent string |
33
33
  | `WEB_BROWSE_DAEMON_PORT` | Daemon port (default: 9377) |
34
- | `WEB_BROWSE_CDP_PORT` | CDP port (default: 9223) |
34
+ | `WEB_BROWSE_CDP_PORT` | CDP port (default: 9225) |
35
35
  | `WEB_BROWSE_DEBUG_DUMP` | Set to `1` to save screenshots/HTML on failures |
36
36
 
37
37
  You can also pass `--browser-bin <path>` as a CLI argument.
package/lib/cdp.js CHANGED
@@ -92,10 +92,20 @@ export async function startBrowserForCdp(preferredPort, profileDir, browserBin =
92
92
  // OS-specific headless flags
93
93
  let headlessArgs;
94
94
  if (IS_MACOS || IS_WINDOWS) {
95
- // macOS and Windows: use standard headless mode
95
+ // macOS and Windows: use standard headless mode.
96
+ // --headless=new injects "HeadlessChrome" into the UA string which is
97
+ // trivially detected by Google (results in /sorry/ CAPTCHA). Override
98
+ // the UA to look like a normal browser.
99
+ // On Linux this isn't needed: --ozone-platform=headless runs a full
100
+ // browser with a normal UA (no "Headless" marker).
101
+ const uaPlatform = IS_MACOS
102
+ ? "(Macintosh; Intel Mac OS X 10_15_7)"
103
+ : "(Windows NT 10.0; Win64; x64)";
104
+ const HEADLESS_UA = `Mozilla/5.0 ${uaPlatform} AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36`;
96
105
  headlessArgs = [
97
106
  "--headless=new",
98
107
  "--window-size=1280,720",
108
+ `--user-agent=${HEADLESS_UA}`,
99
109
  ];
100
110
  } else {
101
111
  // Linux: use ozone headless platform (Wayland/X11 independent)
@@ -193,10 +203,10 @@ export async function resolveCdpOptions({ useCdpFlag, cdpStartFlag, cdpPortValue
193
203
  let effectiveCdpPort = cdpPortValue;
194
204
 
195
205
  if (!effectiveUseCdp && !effectiveCdpStart) {
196
- const cdp9223 = await waitForCdpVersion(9223, 1000);
197
- if (isLikelyUsableBrowserCdp(cdp9223)) {
206
+ const cdp9225 = await waitForCdpVersion(9225, 1000);
207
+ if (isLikelyUsableBrowserCdp(cdp9225)) {
198
208
  effectiveUseCdp = true;
199
- effectiveCdpPort = 9223;
209
+ effectiveCdpPort = 9225;
200
210
  } else {
201
211
  const cdp9222 = await waitForCdpVersion(9222, 1000);
202
212
  if (isLikelyUsableBrowserCdp(cdp9222)) {
@@ -205,7 +215,7 @@ export async function resolveCdpOptions({ useCdpFlag, cdpStartFlag, cdpPortValue
205
215
  } else {
206
216
  effectiveUseCdp = true;
207
217
  effectiveCdpStart = true;
208
- effectiveCdpPort = 9223;
218
+ effectiveCdpPort = 9225;
209
219
  }
210
220
  }
211
221
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ogulcancelik/pi-web-browse",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Web search and content extraction skill for pi-coding-agent. Search the web and fetch pages via a real headless browser (CDP). Works on Linux, macOS, and Windows.",
5
5
  "type": "module",
6
6
  "main": "web-browse.js",
package/web-browse.js CHANGED
@@ -138,7 +138,7 @@ const directUrl = getArg("--url");
138
138
  const fullContent = hasFlag("--full");
139
139
  const cdpStart = hasFlag("--cdp-start");
140
140
  const useCdp = hasFlag("--cdp") || cdpStart;
141
- const cdpPort = parseInt(getArg("--cdp-port") || (cdpStart ? "9223" : "9222"), 10);
141
+ const cdpPort = parseInt(getArg("--cdp-port") || (cdpStart ? "9225" : "9222"), 10);
142
142
  const cdpProfile = getArg("--cdp-profile") || join(homedir(), ".config", "web-browse-cdp-profile");
143
143
  const browserBinArg = getArg("--browser-bin");
144
144
  const stressCount = parseInt(getArg("--stress") || "0", 10);
@@ -446,7 +446,7 @@ async function fetchUrlsWithCdp(urls, truncate, cdpOptions, cdpProfileValue) {
446
446
 
447
447
  async function runDaemon() {
448
448
  const preferredCdpPort = parseInt(
449
- process.env.WEB_BROWSE_CDP_PORT || process.env.LOCAL_SEARCH_CDP_PORT || "9223",
449
+ process.env.WEB_BROWSE_CDP_PORT || process.env.LOCAL_SEARCH_CDP_PORT || "9225",
450
450
  10,
451
451
  );
452
452