Skip to content

sync: dev to extern-contrib - #1042

Merged
PythonSmall-Q merged 41 commits into
extern-contribfrom
dev
Oct 5, 2026
Merged

PythonSmall-Q merged 41 commits into
extern-contribfrom
dev

Conversation

@github-actions

@github-actions github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

sync-branches: New code has just landed in dev, so let's bring extern-contrib up to speed!


Summary by cubic

Brings dev into extern-contrib, fixing the account settings and profile pages after the site migration, enforcing Chinese across the UI, and keeping the navbar spacer visible under browser cosmetic filters.

  • Restores account menu, changelog access, badge editing, and AC code export on the migrated account page; old account links redirect to the current page.
  • Restores profile identity info, rating, tags, solved problems, and last-online time, and rewrites the submission/correct history chart to a single clear chart with theme-aware styling.
  • Forces XMOJ_LANG=zh at document-start for classic and web pages, hides language options in account forms, and removes the language switcher.
  • Prevents browser cosmetic filters from hiding the navbar spacer.
  • Adds Playwright and unit tests covering account settings, Chinese enforcement, profile rendering, and the navbar spacer.

Written for commit 7fca414. Summary will update on new commits.

Review in cubic

Summary by Sourcery

Upgrade the userscript with unified Chinese localization, richer profile and account-management features, and more resilient page and API handling.

New Features:

  • Add a unified Chinese-language experience across classic and contest web pages, including account-language enforcement and resilient fallback handling.
  • Enhance user profiles with solved-problem listings, activity and result charts, avatars, ratings, last-online status, and administrator badge actions.
  • Add badge loading and editing tools to the migrated account settings page while preserving the native account form.
  • Redirect obsolete account-settings links to the migrated account page and update related navigation.

Bug Fixes:

  • Prevent profile and account-page enhancements from destroying native forms, listeners, or server-provided content.
  • Improve API failure handling with timeouts, transport-error reporting, and protection against late responses.

Enhancements:

  • Refactor profile and account-page processing to avoid executing unsafe embedded scripts and to preserve native page behavior.

Build:

  • Bump the script and package version to 3.8.3 and include the expanded test suites in the test command.

Documentation:

  • Update the documented contest-page behavior to reflect the unified Chinese interface.

Tests:

  • Add browser and unit coverage for account settings, Chinese-language enforcement, profile rendering, charts, badge operations, redirects, and API failure recovery.

Chores:

  • Add update metadata for the new release.

boomzero and others added 30 commits October 4, 2026 07:46
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Deploying xmoj-script-dev-channel with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7fca414
Status: ✅  Deploy successful!
Preview URL: https://6c076ae5.xmoj-script-dev-channel.pages.dev

View logs

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry @github-actions[bot], you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 5 days and 5 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Version 3.8.3 introduces centralized Chinese-language enforcement, migrates account settings and badge workflows to the current site routes, substantially modernizes profile rendering while preserving native behavior, and adds extensive browser regression coverage for the new flows.

Sequence diagram for centralized Chinese-language enforcement

sequenceDiagram
    participant Page
    participant XMOJScript
    participant ContestWebApp
    participant SessionStorage

    XMOJScript->>Page: InitializeChineseLanguage()
    Page-->>XMOJScript: initiallyEnglishLanguage
    XMOJScript->>XMOJScript: EnsureChinesePage()
    XMOJScript->>XMOJScript: EnforceChineseView()
    XMOJScript->>ContestWebApp: EnforceChineseView(root)
    alt Contest web app was initially English
        XMOJScript->>SessionStorage: setItem(retryKey, pageKey)
        XMOJScript->>Page: location.reload()
    else Preference already applied or legacy page
        XMOJScript-->>Page: Continue page initialization
    end
Loading

Sequence diagram for account badge loading and saving

sequenceDiagram
    actor User
    participant AccountPage
    participant XMOJScript
    participant XMOJAPI
    participant LocalStorage

    AccountPage->>XMOJScript: InitializeAccountFeatures(authenticated)
    XMOJScript->>XMOJScript: InitializeAccountBadgeEditor()
    XMOJScript->>XMOJScript: InitializeAccountBadgeLoading(content, background, color, status)
    XMOJScript->>XMOJAPI: RequestAPI(GetBadge, UserID)
    XMOJAPI-->>XMOJScript: badge data
    XMOJScript-->>AccountPage: Enable badge fields
    User->>AccountPage: Click 修改标签
    AccountPage->>XMOJScript: SaveAccountBadge(content, background, color)
    XMOJScript->>XMOJAPI: RequestAPI(EditBadge, UserID, Content, BackgroundColor, Color)
    XMOJAPI-->>XMOJScript: Success or error
    alt Success
        XMOJScript->>LocalStorage: remove badge cache keys
        XMOJScript-->>AccountPage: 显示修改成功
    else Failure
        XMOJScript-->>AccountPage: 显示错误并允许重试
    end
Loading

File-Level Changes

Change Details Files
Adds a Chinese-only language enforcement flow across classic pages and the Vue contest app.
  • Sets the language cookie at document start before app navigation requests.
  • Hides language selectors and activates Chinese content without replacing Vue-owned DOM.
  • Preserves account language fields and forces Chinese values during form submission.
  • Adds guarded reload and retry behavior for English contest-app sessions.
XMOJ.user.js
README.md
tests/chinese-language.test.cjs
tests/contest-web.test.cjs
Migrates account settings to the current route while adding resilient badge management.
  • Redirects legacy account links and updates menu/changelog destinations.
  • Keeps the native account form, fields, CSRF data, and submit handlers intact.
  • Adds asynchronous badge loading, editing, validation, cache invalidation, retry, and transport-error handling.
  • Extends RequestAPI with timeouts, HTTP/parse/transport failure callbacks, and duplicate-completion protection.
XMOJ.user.js
tests/account-settings.test.cjs
Reworks user profiles into a richer, non-destructive profile presentation.
  • Extracts solved problems and activity data from rendered HTML without evaluating page scripts.
  • Adds avatar, rating, last-online status, solved links, badges, admin badge controls, and localized profile metadata.
  • Replaces legacy chart rendering with responsive SVG activity and CSS-conic-gradient result charts.
  • Moves native statistics and links instead of recreating them, preserving their handlers and data.
XMOJ.user.js
tests/profile-page.test.cjs
tests/fixtures/profile.html
Updates release metadata and broadens automated regression coverage.
  • Bumps the userscript and package versions to 3.8.3.
  • Registers account, language, and profile test suites in the package test command.
  • Adds browser and VM coverage for redirects, form preservation, retries, parsing safety, chart rendering, and initialization order.
XMOJ.user.js
package.json
Update.json
README.md
tests/account-settings.test.cjs
tests/chinese-language.test.cjs
tests/profile-page.test.cjs
tests/contest-web.test.cjs

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 Oct 4, 2026
@PythonSmall-Q
PythonSmall-Q merged commit f7835f7 into extern-contrib Oct 5, 2026
12 of 13 checks passed
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants