From 58dee6330e80750cd6f7e9440c8a171c051e841c Mon Sep 17 00:00:00 2001 From: SGavrl <277843151+SGavrl@users.noreply.github.com> Date: Sat, 11 Jul 2026 20:36:58 +0000 Subject: [PATCH] browser: skip print-only stylesheets when fetching linked CSS A must not apply on screen; fetching and injecting it let print rules override the screen layout (e.g. the Guardian's print sheet). Skip links whose media is print-only. --- crates/obscura-browser/src/page.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/obscura-browser/src/page.rs b/crates/obscura-browser/src/page.rs index aa9db98..a8a72b1 100644 --- a/crates/obscura-browser/src/page.rs +++ b/crates/obscura-browser/src/page.rs @@ -394,6 +394,16 @@ impl Page { let mut links = Vec::new(); for lid in link_ids { if let Some(node) = dom.get_node(lid) { + // Skip print-only stylesheets: a `` + // must not apply on screen. Some sites (e.g. the + // Guardian) ship a print sheet whose rules otherwise + // overrode the screen masthead/section styling. + if let Some(media) = node.get_attribute("media") { + let m = media.to_ascii_lowercase(); + if m.contains("print") && !m.contains("screen") && !m.contains("all") { + continue; + } + } if let Some(href) = node.get_attribute("href") { links.push(href.to_string()); }