fix: gate MonochromeUI-specific styling in contestrank pages behind flag#939
Merged
fix: gate MonochromeUI-specific styling in contestrank pages behind flag#939
Conversation
Fixes #932. Header black/white forcing and inline style clearing on contestrank-oi.php and contestrank-correct.php now only apply when MonochromeUI is enabled. Badge ranks, color-coded cells, and auto-refresh remain unconditional as part of the base UI. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Reviewer's GuideGates the black-and-white MonochromeUI-specific styling on contest rank pages behind the MonochromeUI feature flag so that default users retain the original colored styles while preserving badges, color coding, and auto-refresh behavior. Sequence diagram for MonochromeUI-dependent styling on contest rank refreshsequenceDiagram
actor User
participant Browser
participant XMOJUserScript
participant Utility
participant RankPage
User->>Browser: Open contestrank page
Browser->>XMOJUserScript: Execute main
XMOJUserScript->>RankPage: Get header cells
XMOJUserScript->>Utility: UtilityEnabled(MonochromeUI)
Utility-->>XMOJUserScript: true or false
alt MonochromeUI enabled
XMOJUserScript->>RankPage: Clear header bgcolor and force black/white styles
else MonochromeUI disabled
XMOJUserScript->>RankPage: Leave header colors unchanged
end
XMOJUserScript->>Browser: Define RefreshRank function
loop Auto-refresh interval
Browser->>XMOJUserScript: Call RefreshRank
XMOJUserScript->>RankPage: Fetch and parse new rank table
XMOJUserScript->>RankPage: TidyTable(rank)
XMOJUserScript->>Utility: UtilityEnabled(MonochromeUI)
Utility-->>XMOJUserScript: true or false
alt MonochromeUI enabled
XMOJUserScript->>RankPage: Clear row backgroundColor
XMOJUserScript->>RankPage: Clear backgroundColor and color for first 5 cells
else MonochromeUI disabled
XMOJUserScript->>RankPage: Preserve original row and cell colors
end
XMOJUserScript->>RankPage: Apply badges and color-coded cells
end
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
c3d5fca to
d07172e
Compare
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider caching
const isMonochrome = UtilityEnabled("MonochromeUI")before the loops and branches instead of callingUtilityEnabledmultiple times inside tight loops to avoid repeated lookups and make the intent clearer. - The header styling and row-clearing logic for
contestrank-oi.phpandcontestrank-correct.phpare now nearly identical; you might want to extract the shared behavior into a helper to reduce duplication and keep future changes in sync.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider caching `const isMonochrome = UtilityEnabled("MonochromeUI")` before the loops and branches instead of calling `UtilityEnabled` multiple times inside tight loops to avoid repeated lookups and make the intent clearer.
- The header styling and row-clearing logic for `contestrank-oi.php` and `contestrank-correct.php` are now nearly identical; you might want to extract the shared behavior into a helper to reduce duplication and keep future changes in sync.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
1 issue found across 3 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="XMOJ.user.js">
<violation number="1" location="XMOJ.user.js:3">
P3: Don't manually bump `@version` here; this repository's release automation owns version updates.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| // ==UserScript== | ||
| // @name XMOJ | ||
| // @version 3.3.3 | ||
| // @version 3.3.4 |
There was a problem hiding this comment.
P3: Don't manually bump @version here; this repository's release automation owns version updates.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At XMOJ.user.js, line 3:
<comment>Don't manually bump `@version` here; this repository's release automation owns version updates.</comment>
<file context>
@@ -1,6 +1,6 @@
// ==UserScript==
// @name XMOJ
-// @version 3.3.3
+// @version 3.3.4
// @description XMOJ增强脚本
// @author @XMOJ-Script-dev, @langningchen and the community
</file context>
Suggested change
| // @version 3.3.4 | |
| // @version 3.3.3 |
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
Fixes #932.
contestrank-oi.php和contestrank-correct.php的黑白极简模式专属样式(表头黑底白字强制样式、行内联样式清除)现在只在开启「极简黑白界面风格」时生效。The MonochromeUI-specific styling on
contestrank-oi.phpandcontestrank-correct.php(black/white header forcing, inline style clearing) is now gated behindUtilityEnabled("MonochromeUI"). Badge ranks, color-coded cells, and auto-refresh remain unconditional.变更内容 Changes
background-color: black !important/color: white !importantforcing underMonochromeUITemp[i].style.backgroundColor = ""row clearing underMonochromeUIMonochromeUIcontestrank-oi.phpandcontestrank-correct.php测试 Test plan
🤖 Generated with Claude Code
Summary by Sourcery
Bug Fixes:
Summary by cubic
Gate MonochromeUI-specific styling behind the feature flag on contest rank pages to stop forced black/white headers when the theme is off. On
contestrank-oi.phpandcontestrank-correct.php, header color forcing and inline style clearing now run only ifUtilityEnabled("MonochromeUI"); badges, color cells, and auto-refresh stay as-is, and the script version updates to3.3.4(prerelease) with notes.Written for commit d07172e. Summary will update on new commits.