fix: navbar listener leaks, download overlap, and web fonts
What does this PR aim to accomplish?:
Fix the navbar resize-listener leak deferred during emergency release #1033 the downloads.php card overlap, and inconsistent navbar fonts between /web and classic pages. With NewTopBar enabled, every refresh previously registered another permanent resize listener: once per second on the contest app and every 100 ms on classic pages. Long-lived tabs accumulated callbacks and could retain navbars replaced by Vue.
Addresses the review finding on #1033.
How does this PR accomplish the above?:
Both UI refresh paths now use a shared navbar styler. The spacer uses a block-level span so legacy body > div selectors continue to target the page content container; the downloads handler previously appended its cards inside the spacer, underneath the fixed navbar. A stable navbar reuses its instance and listener while refreshing the existing styles, spacer and blur overlay. Navbar replacement, removal, or disabling NewTopBar removes the old listener, restores the original navbar styles and classes, removes styler-owned overlays, styles and spacers, and clears the retained navbar reference. Existing page-owned overlays and spacers are preserved with their original inline geometry restored. Resize events skip detached navbars. A shared, deduplicated monochrome font loader runs during early initialization and both fallback paths, so /web requests the same Source Serif 4, Playfair Display and JetBrains Mono stylesheet as classic pages instead of staying on fallback fonts.
Validation: all 18 npm tests passed using installed Chromium, including a new browser regression with 4,000 refreshes, navbar replacement, resize geometry, setting changes, navbar removal, detached-node resize guards, full teardown, style restoration and preservation of page-owned elements. A downloads regression runs the real page handler, reproduces the failure with the old spacer, and verifies that all 15 cards remain below the navbar after the fix and after its height changes. Font-loading coverage checks /web and classic initialization with and without cached Bootstrap CSS, before and after head creation, duplicate initialization, and disabled skins. Userscript syntax and git diff whitespace checks passed. No additional dependency was introduced.
The contributor guide and complete template have been read. This PR targets dev; version metadata is managed by the existing bot. The final checklist remains unchecked because item 11 requires a human to verify both the new and old/classic XMOJ UI; automated browser fixture checks do not assert that manual verification. Please verify both UIs before confirming the checklist.
By submitting this pull request, I confirm the following:
- I have read and understood the contributor's guide, as well as this entire template. I understand which branch to base my commits and Pull Requests against.
- I have commented on my proposed changes within the code.
- I have tested my changes.
- I am willing to help maintain this change if there are issues with it later.
- It is compatible with the GNU General Public License v3.0
- I have squashed any insignificant commits. (
git rebase) - I have checked that another pull request for this purpose does not exist.
- I have considered and confirmed that this submission will be valuable to others.
- I accept that this submission may not be used, and the pull request can be closed at the will of the maintainer.
- I give this submission freely and claim no ownership to its content.
- I have verified that my changes work correctly in both the new UI and the old/classic UI.
- I have read the above and my PR is ready for review. Check this box to confirm