Skip to content

refactor: declare reduce_width.css as manifest content_script#24

Open
skid-dev wants to merge 1 commit into
claude/recursing-goldberg-5b5636from
worktree-agent-aa4f643b788907abd
Open

refactor: declare reduce_width.css as manifest content_script#24
skid-dev wants to merge 1 commit into
claude/recursing-goldberg-5b5636from
worktree-agent-aa4f643b788907abd

Conversation

@skid-dev
Copy link
Copy Markdown
Owner

Summary

  • Added a WXT build:manifestGenerated hook to declare reduce_width.css as a manifest-level content_scripts entry (matches <all_urls>), so the browser loads the stylesheet automatically.
  • Replaced the runtime chrome.scripting.insertCSS call in src/background/events/injects/reduce_width.ts with a tiny executeScript that adds the ultrabox-reduce-content-width class to <body>. Existing setting and is_schoolbox_page gating is preserved.
  • Scoped the CSS rule in public/reduce_width.css to body.ultrabox-reduce-content-width #content so the always-present stylesheet only takes effect when the module enables it.

This demonstrates the pattern; the schooltape-related pure-CSS injectors (launcher_styles.css, post_history_styles.css, news_search_styles.css) are left alone for a follow-up since they have richer conditional logic and shared layering with non-schooltape variants.

Test plan

  • npm install --ignore-scripts succeeds (bun install on Windows fell back to npm as the repo conventions allow)
  • npx wxt prepare succeeds
  • npm run typecheck passes
  • npm run build produces output
  • .output/chrome-mv3/manifest.json contains "content_scripts":[{"matches":["<all_urls>"],"css":["reduce_width.css"]}]
  • Manual browser verification: enable the "Reduce content width" module in the popup on a Schoolbox page, confirm #content is centered at max 1500px; disable + reload, confirm rule no longer applies. (Setting toggle is gated by full page reload, matching the original behavior.)

Move reduce_width.css from chrome.scripting.insertCSS to a manifest-level
content_scripts entry via WXT's build:manifestGenerated hook. The browser
now loads the stylesheet automatically on every page; runtime injection
is replaced with a tiny script that adds a body class to enable the rules,
preserving the existing setting/condition gating.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant