fix: restore account and profile pages and enforce Chinese UI
What does this PR aim to accomplish?:
Fix account navigation and userscript features after XMOJ migrated account editing from /modifypage.php to /modify_user_info.php. Restore missing profile sections when optional requests fail or stall, and replace the broken native submission-history renderer. Remove language selectors and enforce Chinese across the classic and /web UIs.
How does this PR accomplish the above?:
- Point account navigation and the changelog at
/modify_user_info.php. Redirect defunct/modifypage.phplinks to the current endpoint, preserving their query and fragment; remove the obsolete account/password form replacement and POST handler. - Initialize a visible “标签编辑” panel on the current account page before the general page handler. It does not depend on the old navbar, wrapper layout, or the presence of a
<form>and is separate from native account controls. Preserve native fields, CSRF data, and submit listeners; keep AC-code export available. - Disable badge fields until their existing values load, use defaults for incomplete data, and provide retry controls on load failures. Bound badge requests and recover from network, timeout, abort, HTTP, and malformed-response failures. Save badges independently and invalidate only this user's badge cache.
- Render the complete profile synchronously before optional badge and last-online requests. Restore avatar, username, nickname, rating, message link, admin badge actions, and solved problems with their submission counts. Derive avatar and rating from native profile data, retain native statistics nodes and handlers, provide badge retry controls, and replace the overlapping chart legend with a flowing layout. Parse solved-problem links and numeric calls without evaluating native scripts, including for standard uploads.
- Fix #618 by reading the native numeric daily history statements without executing their JavaScript and drawing both series on one SVG graph with a shared date/count scale. Paint translucent accepted bars beneath a thin, translucent submission line; remove visible per-day dot markers so dense history stays readable while keeping hover targets and Chinese tooltips. Keep the graph visible with the default cleanup setting, add Chinese date/count tooltips, resize the axes and date labels for narrow layouts, and inherit light/dark theme colors. Show a clear message for empty or unavailable history; no jQuery, Flot, added library, or extra history request is needed.
- Set the
/weblanguage cookie at document-start and hide navigation, statement, and native account-form language selectors. Select the Chinese account radio and preserve that value on native submit and FormData serialization without disabling its inputs or disturbing other account fields. Persist the classic preference when the current account form is saved; remove calls to the broken/change_lang.phpendpoint and the resulting classic-page reloads. Keep Chinese statements selected after Vue navigation, and prevent/webreload loops with a retry message if its cookie preference is refused. - Recover the remaining
stash@{0}request safeguards: ordinary API requests time out after 30 seconds and report transport failures once; requests with recovery callbacks retain their 15-second limit. The stashes’ contest compatibility, Markdown/TeX copying, and ended-contest fallback are already included through prior merges. Preserve both stash entries and retain the current implementations when resolving their older code. Update the compatibility documentation to reflect Chinese-only UI. - Add offline Chromium regressions for native account fields and listeners, varied account layouts and pages without a form, visible badge loading and saving, incomplete data, pending loads, load/save errors and retries, cache invalidation, defunct-route redirects, navigation, changelog rendering, Chinese language enforcement, and profile restoration during pending and failed requests. Cover profile identity, native links and handlers, missing fields, admin badge actions, standard-upload parsing, and the chart under the monochrome skin. Require the Chinese startup call to exist before asserting initialization order.
Validation: all 90 tests pass using the installed Chromium via XMOJ_CHROMIUM. node --check XMOJ.user.js and git diff --check pass. Use the actual relative-time formatter in profile tests and verify readable last-online text plus the native date tooltip. Exercise the actual document-start redirect and verify classic pages never call the broken language endpoint or reload. Cover wrapped and direct account radio groups, numeric language values, preservation of nickname/CSRF fields and submit handlers, and Chinese serialization after English is reselected programmatically. Visually checked the profile layout using the configured Bootstrap stylesheet and monochrome skin. For the replacement graph, rendered 290 submission records and 224 accepted records from the live profile in light, dark, and mobile layouts; tested rendering with Flot absent, both cleanup settings, safe parsing, sorting/deduplication, data/tooltips, narrow axes, and empty/unavailable history. Verify that both series share one graph and baseline, matching dates align, accepted bars paint behind the thin submission line, both layers use transparency, and dense submission markers remain invisible. Verify that a lone history point is visible and single-date histories render only one centered date label.
Live authenticated account editing was not tested. The final checklist remains unchecked because template item 11 requires human verification with the installed userscript.
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
Summary by Sourcery
Restore userscript account features across XMOJ’s migrated and legacy settings pages.
New Features:
- Support the migrated account settings page while retaining legacy account editing, badge management, and AC-code export capabilities.
Bug Fixes:
- Restore account and changelog navigation after XMOJ moved account editing to the migrated route.
- Prevent account and password page customization from disrupting native forms, CSRF data, or site-installed event handlers.
- Make badge loading and saving resilient to incomplete data and request failures while ensuring controls recover for retries.
Enhancements:
- Share account badge handling across migrated and legacy settings pages and scope badge cache invalidation to the current user.
- Preserve changelog rendering and login or error messages across account-related routes.
Build:
- Bump the userscript and package version to 3.8.3 and include the release update metadata.
Tests:
- Add offline Chromium regression coverage for migrated and legacy account pages, native form preservation, badge failures and retries, navigation, changelog rendering, and related account states.
Summary by cubic
Restores XMOJ account and profile pages after account editing moved to /modify_user_info.php, replaces the broken native submission-history renderer, and enforces Chinese across the classic and /web UIs. Closes #920 and #618, and bumps the userscript and package to 3.8.3.
Bug Fixes
- Account, changelog, and settings-welcome links point to the migrated endpoint; defunct
/modifypage.phplinks redirect with query and fragment preserved, and legacy account editing stays available. - The migrated page keeps its native form, fields, CSRF token, and submit handler; badges are saved separately and AC-code export remains available.
- Badge loading and saving handle missing or invalid data and recover from network, timeout, abort, HTTP, and malformed-response failures without leaving the save button disabled.
- Profile identity, rating, tags, last-online, and solved-problem info render before optional requests, so failures no longer leave sections blank; last-online shows readable text and the chart legend overlap is fixed.
- The submission-history graph is redrawn as SVG from native numeric statements, with submissions and accepted counts in separate aligned panels sharing the same date and count scales; per-day dot markers are removed so dense history forms no blob. No jQuery, Flot, added library, or extra request; handles empty history, narrow layouts, and light/dark themes with a theme-aware border and padding, and stays visible under the default cleanup setting.
- The changelog renders on the migrated route and login/error messages stay intact; the separate password page is retained.
- Language selectors are hidden, the
/webcookie is set at document-start, classic English sessions are switched via the native endpoint, and reload loops are prevented. - Ordinary API requests time out after 30 seconds and report transport failures once; requests with recovery callbacks keep their 15-second limit.
- Adds offline Chromium regressions covering form preservation, badge saves, profile restoration, history rendering, cache invalidation, navigation, changelog rendering, and Chinese enforcement.
Verification note: Live authenticated editing wasn't tested; please verify with the installed userscript in both the new and classic XMOJ UIs before merging.