dembrandt 0.5.1 → 0.6.0

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
@@ -42,10 +42,35 @@ dembrandt bmw.de --dark-mode # Extract colors from dark mode variant
42
42
  dembrandt bmw.de --mobile # Use mobile viewport (390x844, iPhone 12/13/14/15) for responsive analysis
43
43
  dembrandt bmw.de --slow # 3x longer timeouts (24s hydration) for JavaScript-heavy sites
44
44
  dembrandt bmw.de --no-sandbox # Disable Chromium sandbox (required for Docker/CI)
45
+ dembrandt bmw.de --browser=firefox # Use Firefox instead of Chromium (better for Cloudflare bypass)
45
46
  ```
46
47
 
47
48
  Default: formatted terminal display only. Use `--save-output` to persist results as JSON files. Browser automatically retries in visible mode if headless extraction fails.
48
49
 
50
+ ### Browser Selection
51
+
52
+ By default, dembrandt uses Chromium. If you encounter bot detection or timeouts (especially on sites behind Cloudflare), try Firefox which is often more successful at bypassing these protections:
53
+
54
+ ```bash
55
+ # Use Firefox instead of Chromium
56
+ dembrandt bmw.de --browser=firefox
57
+
58
+ # Combine with other flags
59
+ dembrandt bmw.de --browser=firefox --save-output --dtcg
60
+ ```
61
+
62
+ **When to use Firefox:**
63
+ - Sites behind Cloudflare or other bot detection systems
64
+ - Timeout issues on heavily protected sites
65
+ - WSL environments where headless Chromium may struggle
66
+
67
+ **Installation:**
68
+ Firefox browser is installed automatically with `npm install`. If you need to install manually:
69
+
70
+ ```bash
71
+ npx playwright install firefox
72
+ ```
73
+
49
74
  ### W3C Design Tokens (DTCG) Format
50
75
 
51
76
  Use `--dtcg` to export in the standardized [W3C Design Tokens Community Group](https://www.designtokens.org/) format:
@@ -70,7 +95,7 @@ Uses Playwright to render the page, extracts computed styles from the DOM, analy
70
95
 
71
96
  ### Extraction Process
72
97
 
73
- 1. Browser Launch - Launches Chromium with stealth configuration
98
+ 1. Browser Launch - Launches browser (Chromium by default, Firefox optional) with stealth configuration
74
99
  2. Anti-Detection - Injects scripts to bypass bot detection
75
100
  3. Navigation - Navigates to target URL with retry logic
76
101
  4. Hydration - Waits for SPAs to fully load (8s initial + 4s stabilization)
package/index.js CHANGED
@@ -10,7 +10,7 @@
10
10
  import { program } from "commander";
11
11
  import chalk from "chalk";
12
12
  import ora from "ora";
13
- import { chromium } from "playwright-core";
13
+ import { chromium, firefox } from "playwright-core";
14
14
  import { extractBranding } from "./lib/extractors.js";
15
15
  import { displayResults } from "./lib/display.js";
16
16
  import { toW3CFormat } from "./lib/w3c-exporter.js";
@@ -20,8 +20,9 @@ import { join } from "path";
20
20
  program
21
21
  .name("dembrandt")
22
22
  .description("Extract design tokens from any website")
23
- .version("0.5.0")
23
+ .version("0.6.0")
24
24
  .argument("<url>")
25
+ .option("--browser <type>", "Browser to use (chromium|firefox)", "chromium")
25
26
  .option("--json-only", "Output raw JSON")
26
27
  .option("--save-output", "Save JSON file to output folder")
27
28
  .option("--dtcg", "Export in W3C Design Tokens (DTCG) format")
@@ -43,13 +44,20 @@ program
43
44
  let result;
44
45
 
45
46
  while (true) {
47
+ // Select browser type based on --browser flag
48
+ const browserType = opts.browser === 'firefox' ? firefox : chromium;
49
+
46
50
  spinner.text = `Launching browser (${useHeaded ? "visible" : "headless"
47
51
  } mode)`;
48
- const launchArgs = ["--disable-blink-features=AutomationControlled"];
49
- if (opts.noSandbox) {
52
+ // Firefox-specific launch args (Firefox doesn't support Chromium flags)
53
+ const launchArgs = opts.browser === 'firefox'
54
+ ? [] // Firefox has different flags
55
+ : ["--disable-blink-features=AutomationControlled"];
56
+
57
+ if (opts.noSandbox && opts.browser === 'chromium') {
50
58
  launchArgs.push("--no-sandbox", "--disable-setuid-sandbox");
51
59
  }
52
- browser = await chromium.launch({
60
+ browser = await browserType.launch({
53
61
  headless: !useHeaded,
54
62
  args: launchArgs,
55
63
  });
package/lib/extractors.js CHANGED
@@ -29,13 +29,19 @@ export async function extractBranding(
29
29
  const timeouts = [];
30
30
 
31
31
  spinner.text = "Creating browser context with stealth mode...";
32
- const context = await browser.newContext({
32
+ const contextOptions = {
33
33
  viewport: { width: 1920, height: 1080 },
34
34
  userAgent:
35
35
  "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
36
36
  locale: "en-US",
37
- permissions: ["clipboard-read", "clipboard-write"],
38
- });
37
+ };
38
+
39
+ // Only add clipboard permissions for Chromium (Firefox doesn't support them)
40
+ if (browser.browserType().name() === 'chromium') {
41
+ contextOptions.permissions = ["clipboard-read", "clipboard-write"];
42
+ }
43
+
44
+ const context = await browser.newContext(contextOptions);
39
45
 
40
46
  // Full stealth — kills 99% of Cloudflare bot detection
41
47
  spinner.text = "Injecting anti-detection scripts...";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dembrandt",
3
- "version": "0.5.1",
3
+ "version": "0.6.0",
4
4
  "description": "Extract design tokens and brand assets from any website",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -15,7 +15,7 @@
15
15
  "start": "node index.js",
16
16
  "brand-challenge": "node run-no-login-challenge.mjs",
17
17
  "brand-challenge:report": "node run-no-login-challenge.mjs || true",
18
- "install-browser": "npx playwright install chromium || echo 'Playwright browser installation failed. You may need to install system dependencies manually.'"
18
+ "install-browser": "npx playwright install chromium firefox || echo 'Playwright browser installation failed. You may need to install system dependencies manually.'"
19
19
  },
20
20
  "keywords": [
21
21
  "design-tokens",
@@ -38,6 +38,7 @@
38
38
  "license": "MIT",
39
39
  "dependencies": {
40
40
  "@playwright/browser-chromium": "^1.57.0",
41
+ "@playwright/browser-firefox": "^1.57.0",
41
42
  "chalk": "^5.3.0",
42
43
  "commander": "^11.1.0",
43
44
  "ora": "^7.0.1",