refactor: declare reduce_width.css as manifest content_script#24
Open
skid-dev wants to merge 1 commit into
Open
refactor: declare reduce_width.css as manifest content_script#24skid-dev wants to merge 1 commit into
skid-dev wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
build:manifestGeneratedhook to declarereduce_width.cssas a manifest-levelcontent_scriptsentry (matches<all_urls>), so the browser loads the stylesheet automatically.chrome.scripting.insertCSScall insrc/background/events/injects/reduce_width.tswith a tinyexecuteScriptthat adds theultrabox-reduce-content-widthclass to<body>. Existingsettingandis_schoolbox_pagegating is preserved.public/reduce_width.csstobody.ultrabox-reduce-content-width #contentso 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-scriptssucceeds (bun install on Windows fell back to npm as the repo conventions allow)npx wxt preparesucceedsnpm run typecheckpassesnpm run buildproduces output.output/chrome-mv3/manifest.jsoncontains"content_scripts":[{"matches":["<all_urls>"],"css":["reduce_width.css"]}]#contentis centered at max 1500px; disable + reload, confirm rule no longer applies. (Setting toggle is gated by full page reload, matching the original behavior.)