Skip to content

feat(jshttp): optional Firefox/WebKit browser engine + ExecutablePath override#21

Open
knoellp wants to merge 2 commits into
gosom:mainfrom
knoellp:pr/optional-browser-type
Open

feat(jshttp): optional Firefox/WebKit browser engine + ExecutablePath override#21
knoellp wants to merge 2 commits into
gosom:mainfrom
knoellp:pr/optional-browser-type

Conversation

@knoellp

@knoellp knoellp commented May 31, 2026

Copy link
Copy Markdown
Contributor

What

Adds an optional Firefox / WebKit browser engine to the jshttp (Playwright) fetcher, alongside the existing Chromium default.

  • JSFetcherOptions.BrowserType"chromium" (default, also for the empty string), "firefox", "webkit".
  • JSFetcherOptions.ExecutablePath — optional override for the browser binary.
  • Exposed at the app level as WithJS sub-options: scrapemateapp.WithJSBrowserType(...) and scrapemateapp.WithJSExecutablePath(...).

Why

Some targets behave differently across browser engines (bot detection, TLS/JA3 fingerprint, rendering). Being able to opt into Firefox or WebKit — and to point at a custom binary — without leaving the scrapemate fetcher is useful for those cases.

How

  • playwright.Install installs the selected engine; the launch uses the matching playwright.BrowserType (pw.Chromium / pw.Firefox / pw.WebKit).
  • The Chromium-specific launch flags are now applied only when launching Chromium. Firefox and WebKit use Playwright's engine defaults — forwarding the Chromium flags makes Firefox hang on the first NewPage call.
  • The BrowserType/ExecutablePath values are threaded through the existing slot/runtime factories (playwrightRuntimeFactory, playwrightSlotFactory, playwrightRuntime), so both the single-page and multi-page pool paths honour them.

Compatibility

Fully backward-compatible: the empty default maps to Chromium, so callers that never set BrowserType are unaffected.

Tests

Unit tests (no browser required) cover the install-target mapping, the Chromium-only launch-arg handling (incl. DisableImages), and the new config sub-options.

knoellp and others added 2 commits June 1, 2026 00:32
Adds JSFetcherOptions.BrowserType ("chromium" default, "firefox", "webkit")
and JSFetcherOptions.ExecutablePath to override the browser binary, exposed
through scrapemateapp.WithJSBrowserType(...) and WithJSExecutablePath(...) as
WithJS sub-options.

The browser engine is selected via the matching playwright.BrowserType
(Chromium/Firefox/WebKit) and the corresponding install target. Chromium
launch flags are only applied to Chromium — Firefox and WebKit use the
Playwright engine defaults, since forwarding Chromium flags makes Firefox
hang on the first NewPage call.

Backward-compatible: the empty default maps to Chromium, so existing callers
are unaffected. Adds unit tests for the install mapping, the Chromium-only
arg handling, and the new config sub-options.
}
}

func newBrowser(pw *playwright.Playwright, headless, disableImages bool, proxyPool *ProxyPool, ua, browserType, executablePath string) (*browser, error) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If not mistaken when the ua passed is empty then a default will be used.

See line 348:

when a Firefox is returned and ua == '' then

the user agent set will be the one from line 358.

Probably the default UA for firefox/webkit should be used there

// Playwright engine defaults; forwarding Chromium flags hangs Firefox at
// the first NewPage.
if browserType == "" || browserType == "chromium" {
opts.Args = chromiumLaunchArgs(disableImages)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Is there an option to disable image on firefox/webkit?

If yes maybe it can be added

(optional)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants