Skip to content

fix: gate MonochromeUI-specific styling in contestrank pages behind flag#939

Merged
boomzero merged 4 commits intodevfrom
fix/contestrank-monochrome-gate
Mar 15, 2026
Merged

fix: gate MonochromeUI-specific styling in contestrank pages behind flag#939
boomzero merged 4 commits intodevfrom
fix/contestrank-monochrome-gate

Conversation

@boomzero
Copy link
Member

@boomzero boomzero commented Mar 15, 2026

概要 Summary

Fixes #932.

contestrank-oi.phpcontestrank-correct.php 的黑白极简模式专属样式(表头黑底白字强制样式、行内联样式清除)现在只在开启「极简黑白界面风格」时生效。

The MonochromeUI-specific styling on contestrank-oi.php and contestrank-correct.php (black/white header forcing, inline style clearing) is now gated behind UtilityEnabled("MonochromeUI"). Badge ranks, color-coded cells, and auto-refresh remain unconditional.

变更内容 Changes

  • Gate header background-color: black !important / color: white !important forcing under MonochromeUI
  • Gate Temp[i].style.backgroundColor = "" row clearing under MonochromeUI
  • Gate first-5-cells style clearing under MonochromeUI
  • Applies to both contestrank-oi.php and contestrank-correct.php

测试 Test plan

  • 关闭「极简黑白界面风格」,访问比赛排行榜,确认表头不再强制黑白样式
  • 开启「极简黑白界面风格」,访问比赛排行榜,确认表头正常显示黑白样式
  • 两种情况下,名次徽章、色块和自动刷新功能正常工作

🤖 Generated with Claude Code

Summary by Sourcery

Bug Fixes:

  • Ensure contest rank table headers and row style clearing only apply when the MonochromeUI option is enabled, so standard themes no longer get forced black-and-white styling.

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.php and contestrank-correct.php, header color forcing and inline style clearing now run only if UtilityEnabled("MonochromeUI"); badges, color cells, and auto-refresh stay as-is, and the script version updates to 3.3.4 (prerelease) with notes.

Written for commit d07172e. Summary will update on new commits.

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>
@sourcery-ai
Copy link

sourcery-ai bot commented Mar 15, 2026

Reviewer's Guide

Gates 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 refresh

sequenceDiagram
    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
Loading

File-Level Changes

Change Details Files
Gate contestrank header black/white styling behind MonochromeUI flag
  • Wrap header cell bgcolor removal and forced black/white inline styles in a UtilityEnabled("MonochromeUI") check for OI rank page processing
  • Wrap header cell link color forcing in the same MonochromeUI conditional
  • Apply the same MonochromeUI-guarded header styling logic to the correct-answer rank page headers
XMOJ.user.js
Gate row and leading cell style clearing behind MonochromeUI flag
  • Guard per-row backgroundColor reset with UtilityEnabled("MonochromeUI") so default theme rows keep their background
  • Guard clearing of backgroundColor and color for the first up-to-5 cells in each row with UtilityEnabled("MonochromeUI") on the OI rank page
  • Apply the same MonochromeUI-guarded row and leading cell clearing logic to the correct-answer rank page processing
XMOJ.user.js

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@hendragon-bot hendragon-bot bot added the user-script This issue or pull request is related to the main user script label Mar 15, 2026
@github-actions github-actions bot force-pushed the fix/contestrank-monochrome-gate branch from c3d5fca to d07172e Compare March 15, 2026 07:31
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • 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.
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.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Member

@PythonSmall-Q PythonSmall-Q left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

@cubic-dev-ai cubic-dev-ai bot Mar 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Fix with Cubic

@boomzero boomzero merged commit dddadbf into dev Mar 15, 2026
7 checks passed
@boomzero boomzero deleted the fix/contestrank-monochrome-gate branch March 15, 2026 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M user-script This issue or pull request is related to the main user script

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants