Skip to content

[Wait until all merged] Sync Dev#956

Draft
PythonSmall-Q wants to merge 63 commits intomasterfrom
dev
Draft

[Wait until all merged] Sync Dev#956
PythonSmall-Q wants to merge 63 commits intomasterfrom
dev

Conversation

@PythonSmall-Q
Copy link
Member

@PythonSmall-Q PythonSmall-Q commented Mar 22, 2026

Summary by Sourcery

Update the userscript and website to add an image enlargement utility, improve contest/problem and status filtering UX, and introduce a standalone web UI for XMOJ private messages, along with minor UI tweaks and asset/CDN updates.

New Features:

  • Expose a reusable contest problem list loader with a refresh control in the problem switcher.
  • Add a configurable image enlargement feature that overlays images with zoom, pan, navigation, and download support.
  • Introduce a web-based private message UI (messages.html) that allows viewing, composing, and uploading images in XMOJ messages without installing the userscript.

Bug Fixes:

  • Fix a Chinese typo in the contest submission ended message text.
  • Ensure new Bootstrap status filter selects correctly reflect the current query parameters instead of always defaulting to 'all'.

Enhancements:

  • Preserve selected filters on the status page when using the redesigned Bootstrap form.
  • Tighten interaction between monochrome UI mode and contest ranking tables so styles only change when the mode is enabled.
  • Suppress built‑in translation controls on problem pages to avoid conflicts with the script.

Build:

  • Bump script and package version numbers from 3.3.0 to 3.3.5 and point the website to Bootstrap assets hosted on cdnjs instead of bootcdn.

Documentation:

  • Update the landing page to reference the new web-based short message UI and link to it for platforms that cannot use userscripts.

Summary by cubic

Ships v3.3.5 with a new ImageEnlarger in the userscript and a standalone messages.html WebUI for short messages. Also improves contest problem switching and status.php filters, gates monochrome styling, removes the problem translate buttons, and switches the site CDN.

  • New Features

    • XMOJ.user.js ImageEnlarger: modal viewer with zoom/pan, mouse wheel, keyboard, and download; toggleable; applies to dynamic images and skips avatar hosts.
    • messages.html: read/send short messages on any device (PHPSESSID or bookmarklet login), image paste/upload, user badges, contact search, dark mode, auto-scroll/refresh.
    • Problem Switcher: fetches/caches contest problem list and adds a “刷新” action; status.php shows and preserves current query values with basic validation.
  • Bug Fixes

    • Gate contestrank header black/white styling behind MonochromeUI.
    • Remove problem translate buttons on problem pages.
    • Switch Bootstrap CDN to cdnjs; update package.json/Update.json to 3.3.5.

Written for commit 3ea071d. Summary will update on new commits.

PythonSmall-Q and others added 30 commits March 7, 2026 09:07
Introduce an ImageEnlarger utility: add a toggle option to the feature list and implement a modal image viewer with CSS, toolbar (zoom in/out, reset, save), keyboard shortcuts, and click-to-open behavior. Images are annotated with a preview class and the feature ignores gravatar/cravatar sources; it applies to existing and dynamically added images via a MutationObserver. Errors are logged and surface a DebugMode alert when enabled.
…rc, and MutationObserver performance

Co-authored-by: PythonSmall-Q <106425289+PythonSmall-Q@users.noreply.github.com>
Co-authored-by: PythonSmall-Q <106425289+PythonSmall-Q@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Shan Wenxiao <seanoj_noreply@yeah.net>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Shan Wenxiao <seanoj_noreply@yeah.net>
Fix ImageEnlarger: accessibility, modal re-entry, responsive images, MutationObserver perf
Co-authored-by: PythonSmall-Q <106425289+PythonSmall-Q@users.noreply.github.com>
Co-authored-by: PythonSmall-Q <106425289+PythonSmall-Q@users.noreply.github.com>
Co-authored-by: PythonSmall-Q <106425289+PythonSmall-Q@users.noreply.github.com>
Fix image viewer: broken pan, missing wheel zoom, download navigates instead of saving
Add ImageEnlarger feature with modal viewer
* Update Update.json

Signed-off-by: Zhu Chenrui <boomzero_zcr@outlook.com>

* Parse release notes from comment block

(cherry picked from commit c7137ff)

* Update bug.yml

Signed-off-by: Zhu Chenrui <boomzero_zcr@outlook.com>
(cherry picked from commit 07d7590)

Update feature.yml

Signed-off-by: Zhu Chenrui <boomzero_zcr@outlook.com>
(cherry picked from commit 1a99430)

Update docs.yml

Signed-off-by: Zhu Chenrui <boomzero_zcr@outlook.com>
(cherry picked from commit 6017bcf)

* Update GitHub Actions workflow to skip bot triggers

Signed-off-by: Shan Wenxiao <seanoj_noreply@yeah.net>

* Prevent UpdateVersion from running if last commit was by github-actions[bot]

This prevents infinite loops where the bot commits version updates,
which triggers the workflow again, causing another commit.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* Allow metadata updates on edited PRs after bot version commit

The last-commit-author guard now only exits for non-edited events,
so PR title/body changes still update Update.json metadata even
when the branch tip is a github-actions[bot] commit.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Allow metadata updates on edited PRs after bot version commit

Exclude all bot actors (not just github-actions[bot]) from triggering
the UpdateVersion workflow, preventing loops from AI code review bots.
Allow edited events through the script-level guard so PR title/body
changes still update Update.json metadata.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix Problem Switcher Not Update

* Fix Problem Switcher Not Update

* 3.3.2

* Update version info to 3.3.2

* Fix Version List (1.999999.0 -> 1.10.0)

Signed-off-by: zsTree <wa2025666@gmail.com>

* Update time and description of 3.3.2

* Fix Problem Switcher Null Problem

Signed-off-by: zsTree <wa2025666@gmail.com>

* Update time and description of 3.3.2

* Fix XSS bug

Signed-off-by: zsTree <wa2025666@gmail.com>

* Update time and description of 3.3.2

---------

Signed-off-by: Zhu Chenrui <boomzero_zcr@outlook.com>
Signed-off-by: Shan Wenxiao <seanoj_noreply@yeah.net>
Signed-off-by: zsTree <wa2025666@gmail.com>
Co-authored-by: Zhu Chenrui <boomzero_zcr@outlook.com>
Co-authored-by: Shan Wenxiao <seanoj_noreply@yeah.net>
Co-authored-by: boomzero <thomas_rainbowfish@icloud.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Signed-off-by: zsTree <wa2025666@gmail.com>
Signed-off-by: zsTree <wa2025666@gmail.com>
Signed-off-by: zsTree <wa2025666@gmail.com>
Signed-off-by: zsTree <wa2025666@gmail.com>
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>
boomzero and others added 24 commits March 15, 2026 16:57
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Desktop/mobile login tab priority: bookmarklet on desktop (pointer: fine), session on mobile
- Replace sender name links with Bootstrap popovers showing user info popup
- Image zoom: cursor: zoom-in/zoom-out, title tooltip on images
- Global Ctrl+V paste handler for images anywhere in thread view
- Auto-resize compose textarea as user types

Co-authored-by: PythonSmall-Q <106425289+PythonSmall-Q@users.noreply.github.com>
Co-authored-by: PythonSmall-Q <106425289+PythonSmall-Q@users.noreply.github.com>
Co-authored-by: PythonSmall-Q <106425289+PythonSmall-Q@users.noreply.github.com>
…nfo modal

Co-authored-by: PythonSmall-Q <106425289+PythonSmall-Q@users.noreply.github.com>
…in userinfo fetch

Co-authored-by: PythonSmall-Q <106425289+PythonSmall-Q@users.noreply.github.com>
Co-authored-by: PythonSmall-Q <106425289+PythonSmall-Q@users.noreply.github.com>
…ck + auto-scroll fix

Co-authored-by: PythonSmall-Q <106425289+PythonSmall-Q@users.noreply.github.com>
feat(messages.html): user badges, contact search, auto-scroll to latest
Add caption "点击任意行打开对话 →" above table and a › chevron
in a trailing column on each row.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add update information for version 3.3.5 including notes and description.

Signed-off-by: Shan Wenxiao <seanoj_noreply@yeah.net>
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Signed-off-by: Shan Wenxiao <seanoj_noreply@yeah.net>
Restored: contact search, renderMailList, mailListCache, user badges,
user info modal, userSpan, auto-resize textarea, global paste handler,
requestAnimationFrame scroll, setLoginTab, dark-mode table-primary fix.

Added on top: caption "点击任意行打开对话 →" and › chevron column
to make list rows obviously clickable.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Shan Wenxiao <seanoj_noreply@yeah.net>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Shan Wenxiao <seanoj_noreply@yeah.net>
Signed-off-by: Shan Wenxiao <seanoj_noreply@yeah.net>
feat: messages.html WebUI for short messages
@sourcery-ai
Copy link

sourcery-ai bot commented Mar 22, 2026

Reviewer's Guide

Updates the XMOJ userscript and web UI to version 3.3.5 by extracting reusable contest problem-list fetching logic, adding a configurable image-enlargement feature, improving status filter state handling, guarding monochrome rank-table styling behind a flag, fixing minor text issues, switching CDN origins, and introducing a standalone short-message Web UI (messages.html) that talks to the existing API and supports rich messaging and image upload without the userscript.

Sequence diagram for contest problem list fetching and refreshing

sequenceDiagram
    participant User
    participant ProblemPage as Problem_page_script
    participant GetContestProblemList as GetContestProblemList_fn
    participant XMOJContest as xmoj.tech_contest_php
    participant LocalStorage

    User->>ProblemPage: Open problem.php?cid&pid
    ProblemPage->>LocalStorage: get(UserScript-Contest-{cid}-ProblemList)
    alt ProblemList not in LocalStorage
        ProblemPage->>GetContestProblemList: GetContestProblemList(false)
        GetContestProblemList->>XMOJContest: fetch(contest.php?cid={cid})
        XMOJContest-->>GetContestProblemList: HTML (problemset table)
        GetContestProblemList->>GetContestProblemList: parse DOM & build problemList
        GetContestProblemList->>LocalStorage: set(UserScript-Contest-{cid}-ProblemList, JSON)
        GetContestProblemList-->>ProblemPage: resolved
        ProblemPage->>LocalStorage: get(UserScript-Contest-{cid}-ProblemList)
    end
    ProblemPage->>ProblemPage: render problemSwitcher UI from ContestProblemList

    User->>ProblemPage: Click refresh link
    ProblemPage->>GetContestProblemList: GetContestProblemList(true)
    GetContestProblemList->>XMOJContest: fetch(contest.php?cid={cid})
    XMOJContest-->>GetContestProblemList: HTML (updated)
    GetContestProblemList->>GetContestProblemList: rebuild problemList
    GetContestProblemList->>LocalStorage: update Contest-{cid}-ProblemList
    GetContestProblemList->>ProblemPage: if RefreshList then location.reload()
Loading

Sequence diagram for WebUI login and session establishment

sequenceDiagram
    actor User
    participant Browser
    participant XMOJSite as xmoj.tech
    participant MessagesHTML as messages_html
    participant LocalStorage

    User->>Browser: Open xmoj.tech and log in
    Browser->>XMOJSite: POST login
    XMOJSite-->>Browser: Set PHPSESSID cookie

    par Manual_session_login
        User->>Browser: Open messages.html
        Browser->>MessagesHTML: load page
        MessagesHTML->>LocalStorage: load stored session (if any)
        alt No stored session
            User->>MessagesHTML: Enter username + PHPSESSID
            MessagesHTML->>LocalStorage: save username, PHPSESSID
        end
        MessagesHTML-->>User: Show inbox via API
    and Bookmarklet_login
        User->>Browser: Click bookmarklet on xmoj.tech
        Browser->>Browser: Extract username + PHPSESSID from page and cookie
        Browser->>Browser: Redirect to messages.html#session=username:PHPSESSID
        Browser->>MessagesHTML: load page with hash
        MessagesHTML->>MessagesHTML: parse #session
        MessagesHTML->>LocalStorage: save username, PHPSESSID
        MessagesHTML-->>User: Show inbox via API
    end
Loading

File-Level Changes

Change Details Files
Extract contest problem list fetching into a reusable function and add a manual refresh control to the problem switcher.
  • Introduce unsafeWindow.GetContestProblemList to fetch contest problems, parse the DOM, and cache them in localStorage, with optional page reload on refresh.
  • Refactor existing inline contest problem list fetch on problem.php to call the new function and then reuse the cached result.
  • Add a refresh link/button to the contest problem switcher UI wired to GetContestProblemList(true), plus corresponding CSS for the .refreshList class.
XMOJ.user.js
Improve problem page behavior and status filter persistence.
  • Remove built-in CN↔EN translation buttons on problem.php before custom rendering to avoid UI conflicts.
  • On status.php, derive current filter values (problem_id, language, jresult) from URL parameters, validate them, and set the new Bootstrap-based form fields accordingly so filters persist after reload.
  • Adjust default option markup for language and jresult selects to avoid hardcoded selected attributes and rely on dynamic selection logic.
XMOJ.user.js
Gate monochrome rank-table styling behind the MonochromeUI utility flag.
  • Wrap header styling overrides for OI and Correct rank tables in UtilityEnabled("MonochromeUI") checks so they only apply when the monochrome UI option is enabled.
  • Similarly guard row background and cell color resets behind the same flag while keeping logic that normalizes content and medal display unchanged.
XMOJ.user.js
Add a configurable image enlargement feature across the site, integrated with the userscript’s utilities and permissions.
  • Register a new utility option ImageEnlarger in the settings menu and gate the feature on UtilityEnabled("ImageEnlarger").
  • Inject CSS and create a full-screen modal viewer with zoom, pan (mouse and touch), keyboard navigation, and next/prev controls for images on the page.
  • Attach click handlers to eligible images (excluding avatar sources) via a MutationObserver, marking them with .xmoj-image-preview and opening the modal on click.
  • Implement zoom controls, drag-to-pan, mouse wheel zoom, swipe navigation, and keyboard shortcuts while keeping state (zoom, pan, current index) inside the modal.
  • Provide a Save Image button that downloads the current image using GM_xmlhttpRequest with a blob fallback, with DebugMode-aware error reporting.
XMOJ.user.js
Fix minor text and UX issues in the userscript.
  • Correct a Chinese wording typo in a contest submission error message (“像题目” → “向题目”).
  • Ensure console log mirrors the corrected wording.
  • Tidy CSS for .refreshList and other minor style consistency issues.
XMOJ.user.js
Update site index to use a different CDN and expose the WebUI for short messages.
  • Switch Bootstrap 5.2.3 CSS/JS CDN references from cdn.bootcdn.net to cdnjs.cloudflare.com.
  • Add a navbar link to messages.html labeled as an Alpha web UI for short messages, and update the short-message feature description to mention the WebUI for devices that can’t install user scripts.
index.html
Align package metadata with the new release version and maintain update metadata.
  • Bump package.json version from 3.3.0 to 3.3.5.
  • Preserve Update.json file (no shown changes in diff).
package.json
Update.json
Introduce a standalone, responsive WebUI (messages.html) for XMOJ short messages with session-based login, message list, threads, and image upload support.
  • Create messages.html with Bootstrap 5.3, dark-mode-aware styling, and a navbar exposing theme toggle and logout, plus a login screen with manual session login and bookmarklet-based login instructions for multiple browsers.
  • Persist session info (username, PHPSESSID) in localStorage and construct API payloads compatible with the existing XMOJ-Script backend (Authentication + Data + Version fields).
  • Implement a mail list view that fetches GetMailList, caches results for client-side search, shows unread counts, and navigates to per-user threads; also adds a compose-new-message panel.
  • Implement a thread view that fetches GetMail for a selected user, renders messages as sanitized Markdown using marked + DOMPurify, highlights unread incoming messages, and auto-scrolls to bottom while preserving user scroll when appropriate.
  • Integrate user badges and lightweight user info modal by scraping userinfo.php and caching badge data in localStorage with TTL, reusing the same badge structure as the userscript.
  • Add sending capabilities for both thread view and global compose panel via SendMail, including loading indicators, keyboard shortcuts, and error toasts.
  • Implement image upload into messages via UploadImage API (PNG/JPEG up to 5 MB), supporting file picker and clipboard paste, inserting Markdown image links that point to the assets domain.
  • Add a simple single-image lightbox modal for message images, plus global paste handling and auto-resizing textareas for better mobile UX.
  • Implement auto-refresh for open threads with pause-on-background, plus overall toast-based feedback and theme persistence using localStorage and prefers-color-scheme.
messages.html

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 user-script This issue or pull request is related to the main user script website This issue or pull request is related to website related files labels Mar 22, 2026
@PythonSmall-Q PythonSmall-Q changed the title Sync Dev [Wait until all merged] Sync Dev Mar 22, 2026
var ans = true;
if (!patrn.exec(str)) ans = false;
return ans;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XXL user-script This issue or pull request is related to the main user script website This issue or pull request is related to website related files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants