修正 ForceMobileView 放大字體導致行距重疊並加入 Steve Blank 測資#52
Merged
ChrisTorng merged 5 commits intoApr 12, 2026
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…, add Steve Blank fixture and tests ### Motivation - Prevent text-line overlap caused by font-size-only boosts by enforcing a readable pixel `line-height` on surrounding elements. - Reduce excessive side whitespace on narrow/mobile screens to keep total side padding/margin minimal. - Add a captured Steve Blank page and automated tests to reproduce and guard against a line-height overlap regression. ### Description - Tightened mobile side spacing by changing `MAX_SIDE_SPACING_PX` from `8` to `2` and adjusting the injected CSS padding from `min(2vw, 8px)` to `min(0.6vw, 2px)`. - Replace ratio-only `line-height` enforcement for boosted small text with a pixel minimum (`minFontSizePx * MIN_LINE_HEIGHT_RATIO`) and add `enforceReadableLineHeight` to raise ancestor `line-height` where needed, tracked with new attributes `data-tm-force-width-min-line-height-only*`. - Extend cleanup in `clearMinimumFontSize` to restore `line-height` changes made by the new enforcement logic. - Bump userscript version to `2026-04-12_1.7.1`. - Add a new captured fixture `tests/Force Mobile View/steveblank.com_2026_04_09_nowhere-is-safe.html` and update `scripts/test-force-mobile-view.js` to load and validate it, update several assertions (expected `line-height` and spacing values), and add a new automated test simulating the legacy font-only boost regression. - Update `TestCases.md` to document the Steve Blank test and clarify minor test notes for daringfireball entry. ### Testing - Ran the Force Mobile View test file with `node ./scripts/test-force-mobile-view.js`, which executes the captured-page harness and assertions; all updated tests passed. - The updated fixture validation test confirmed the new Steve Blank capture contains `CONTENT_CLASS: VALID_ARTICLE_CONTENT` and the new regression test assertions succeeded.
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.
Motivation
https://steveblank.com/2026/04/09/nowhere-is-safe/加入自動化回歸測試以重現與驗證該問題。Description
src/ForceMobileView.user.jsmetadata 版本更新為2026-04-12_1.7.0並在字體強制邏輯中改為以像素值設定最小line-height(px),取代單純使用比例值,避免放大後行盒重疊。enforceReadableLineHeight,當祖先元素的計算行高過小時會臨時提升並儲存原始 inline 屬性以便還原。data-tm-force-width-min-line-height-only*)並在停用時完整還原所有變更。tests/Force Mobile View/steveblank.com_2026_04_09_nowhere-is-safe.html,並擴充scripts/test-force-mobile-view.js:載入該 fixture、先模擬舊的「僅放大字體」會重疊的情境,再驗證新邏輯能提升父層行高以避免重疊;同時更新TestCases.md並標註為自動化測試。Testing
node --test scripts/test-force-mobile-view.js,所有子測試通過(6 個子測試皆通過)。Codex Task