1
Fork 0
mirror of https://github.com/thegeneralist01/archivr synced 2026-07-21 18:55:36 +02:00

singlefile: force --window-size=1920,1080 for viewport-dependent CSS preservation

Add --window-size=1920,1080 to the Chromium flags passed via --browser-args.
This makes the existing --remove-unused-styles=false and
--remove-alternative-medias=false effective for real @media rules
and responsive styles (headless default is small).

Also document in ARCHIVR_CHROME_ARGS that users can override by
supplying their own --window-size in the env var.
This commit is contained in:
TheGeneralist 2026-07-05 15:40:58 +02:00
parent fb1115a409
commit 84c5730b6a
Signed by: thegeneralist01
SSH key fingerprint: SHA256:pp9qddbCNmVNoSjevdvQvM5z0DHN7LTa8qBMbcMq/R4
2 changed files with 10 additions and 0 deletions

View file

@ -72,9 +72,16 @@ fn save_with(
// then append any extra flags from ARCHIVR_CHROME_ARGS (space-separated). // then append any extra flags from ARCHIVR_CHROME_ARGS (space-separated).
// Docker containers running as root need "--no-sandbox" here because // Docker containers running as root need "--no-sandbox" here because
// Chromium refuses to start as root without it. // Chromium refuses to start as root without it.
//
// --window-size is set to a realistic desktop viewport so that
// --remove-alternative-medias=false and --remove-unused-styles=false
// actually preserve responsive @media rules and styles that only match
// at normal screen widths (headless Chromium defaults to a small viewport
// that would otherwise defeat the preservation flags).
let mut chrome_flags = vec![ let mut chrome_flags = vec![
"--disable-web-security".to_string(), "--disable-web-security".to_string(),
format!("--user-data-dir={}", chrome_data_dir.display()), format!("--user-data-dir={}", chrome_data_dir.display()),
"--window-size=1920,1080".to_string(),
]; ];
if let Ok(extra) = std::env::var("ARCHIVR_CHROME_ARGS") { if let Ok(extra) = std::env::var("ARCHIVR_CHROME_ARGS") {
chrome_flags.extend(extra.split_whitespace().filter(|s| !s.is_empty()).map(str::to_string)); chrome_flags.extend(extra.split_whitespace().filter(|s| !s.is_empty()).map(str::to_string));

View file

@ -314,6 +314,9 @@ dependencies (Chromium, Node.js, Python) land in the final layer.
- Space-separated extra flags appended to Chromium's `--browser-args`. The Docker - Space-separated extra flags appended to Chromium's `--browser-args`. The Docker
image sets this to `--no-sandbox` because Chromium refuses to run as root without image sets this to `--no-sandbox` because Chromium refuses to run as root without
it. Leave unset when running natively (Nix, Linux desktop). it. Leave unset when running natively (Nix, Linux desktop).
A `--window-size=1920,1080` is always passed to provide a realistic desktop
viewport (so responsive @media rules and styles are evaluated and preserved
correctly). Supply your own `--window-size=...` here to override.
- `ARCHIVR_TWITTER_CREDENTIALS_FILE` - `ARCHIVR_TWITTER_CREDENTIALS_FILE`
- Required for tweet/thread scraping inputs such as `tweet:ID` and `x:thread:ID`. - Required for tweet/thread scraping inputs such as `tweet:ID` and `x:thread:ID`.
- Must point to a cookies file for the vendored scraper. - Must point to a cookies file for the vendored scraper.