daijro / camoufox

🦊 Anti-detect browser
https://camoufox.com
Mozilla Public License 2.0
751 stars 55 forks source link

Raw camoufox binary #103

Open bestplay9384 opened 1 week ago

bestplay9384 commented 1 week ago

Hi,

I've looked through code & commits in repo, very good work! :) However no matter i try i cannot start the browser correctly.

What am i trying to accomplish? I've built a docker container based on AmazonLinux2023 (fedora), installed every package that was missing and needed by camoufox (docs). Now i'm trying to start camoufox-bin, but via code. All my code is in NodeJS that is why i cannot use Camoufox python library (and this is a must have unfortunately because all my scraping scripts (300+) are based on puppeteer-core interfaces - NodeJS).

What i tried? I've thought there is a chance to start camoufox like that:

  1. Define CAMOUCONFIG[\d+] ENV variables with NodeJS by breaking config JSON into parts as launcher code does it.
  2. Run raw camoufox-bin/launch via code (puppeteer.connect / puppeteer.launch) (with args: --remote-debugging-port 9223 -headless)
  3. Binary starts up with websocket debugging port opened and puppeteer connects to it.
*** You are running in headless mode.
[GFX1-]: FireTestProcess failed: Failed to spawn child process “/usr/local/bin/camoufox/glxtest” (No such file or directory)
JavaScript warning: resource://services-settings/Utils.sys.mjs, line 57: unreachable code after return statement
JavaScript warning: resource://services-settings/Utils.sys.mjs, line 119: unreachable code after return statement
Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: ManageChildProcess failed
WebDriver BiDi listening on ws://127.0.0.1:9223
console.error: "Ignoring protocol handler for mailto without a uriTemplate!"
console.error: ({})
console.error: SearchService: "#init: failure initializing search:" (new TypeError("defaultsConfig is undefined", "resource://gre/modules/SearchEngineSelector.sys.mjs", 702))
JavaScript error: resource://gre/modules/SearchEngineSelector.sys.mjs, line 702: TypeError: defaultsConfig is undefinedErr: JavaScript error: resource://gre/modules/SearchEngineSelector.sys.mjs, line 702: TypeError: defaultsConfig is undefined
JavaScript error: resource://gre/modules/SearchEngineSelector.sys.mjs, line 702: TypeError: defaultsConfig is undefinedErr: JavaScript error: resource://gre/modules/SearchEngineSelector.sys.mjs, line 702: TypeError: defaultsConfig is undefined
JavaScript error: resource://gre/modules/SearchEngineSelector.sys.mjs, line 702: TypeError: defaultsConfig is undefined
JavaScript error: resource://gre/modules/PromiseWorker.sys.mjs, line 75: Error: Could not get children of `/root/.camoufox/9dq0lrfh.default-default/thumbnails': directory does not exist (NS_ERROR_FILE_NOT_FOUND)
console.error: WebExtensions:
  Message: TypeError: defaultsConfig is undefined
console.error: "Could not parse ASRouter preference. Try resetting browser.newtabpage.activity-stream.asrouter.providers.snippets in about:config."
console.error: SearchSettings: "_write: Could not write to settings file:" (new Error("cannot write without any engine.", "resource://gre/modules/SearchSettings.sys.mjs", 335))
1732523000069   RemoteAgent INFO    Perform WebSocket upgrade for incoming connection from 127.0.0.1:52710
BidiBrowser { protocol: 'webDriverBiDi' }
  1. This is the place that code is stuck and after some time it timesout from puppeteer itself, it looks like browser disallows to control it via websocket or something. I've also tried to run binary manualy via NodeJS child_process.exec but effect is the same.

ProtocolError: browsingContext.create timed out. Increase the 'protocolTimeout' setting in launch/connect calls for a higher timeout if needed. -> at BidiBrowserContext.newPage (in puppeteer context)


Am i missing something? I've noticed there is no firefox profile in my args, but still it should start up with some defaults imho, am i right?

Last question, are You planning maybe to release binary itself as a standalone firefox "fork" so playwright nor python are necessary?

Amazing work, thanks for help :)

daijro commented 13 hours ago

Hello,

Camoufox uses Playwright's Juggler protocol to control the browser, which is implemented separately from Firefox's native RDP API. Since Firefox's remote debug server is detectable (see #90), I don't have plans to support Puppeteer any time soon.


If you're looking to use Camoufox in NodeJS, you could launch a remote server using the Python library (see here), then connect to it from NodeJS Playwright:

import playwright from "playwright-core";

// Connect to the Python server
const pwEndpoint = `ws://localhost:36539/bf81a6ed494f6ecf3698ca7570506203`;
const browser = await playwright.firefox.connect(pwEndpoint);
const context = await browser.newContext();
const page = await context.newPage();

Hope this helps :+1: