Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Update.json
Original file line number Diff line number Diff line change
Expand Up @@ -3883,6 +3883,28 @@
}
],
"Notes": "用户评分重新设计:从「AC 率 × 1000」改为综合做题量、准确度和坚持度的 0–3000 分,更难刷分,用户名颜色改为六档。详见 https://docs.xmoj-script.uk/features/rating.html"
},
"3.8.7": {
"UpdateDate": 1791247094090,
"Prerelease": true,
"UpdateContents": [
{
"PR": 1049,
"Description": "Show script admins with violet names instead of a badge"
}
],
"Notes": "脚本管理员的用户名改为紫色显示(悬停提示「脚本管理员」),不再单独显示「脚本管理员」徽章,为自定义徽章腾出空间。"
},
"3.8.8": {
"UpdateDate": 1791248477470,
"Prerelease": true,
"UpdateContents": [
{
"PR": 1051,
"Description": "Fix image enlarger and minimalist skin on video replay pages; add page title"
}
],
"Notes": "- 修复回放视频进度条拖动球被当作图片放大的问题\n- 修复极简黑白界面下视频播放器按钮出现灰色方框的问题\n- 回放页面增加页面标题"
}
}
}
43 changes: 27 additions & 16 deletions XMOJ.user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==UserScript==
// @name XMOJ
// @version 3.8.6
// @version 3.8.8
// @description XMOJ增强脚本
// @author @XMOJ-Script-dev, @langningchen and the community
// @namespace https://github/langningchen
Expand Down Expand Up @@ -269,7 +269,8 @@
--mono-gray-500: #a3a3a3;
}

* {
/* The video player draws its controls with rounded shapes and sized icons; leave it alone */
*:not(.prism-player *) {
border-radius: 0 !important;
box-shadow: none !important;
}
Expand Down Expand Up @@ -613,7 +614,7 @@
}
}
/* Contain images */
img {
img:not(.prism-player img) {
max-width: 100% !important;
height: auto !important;
}
Expand Down Expand Up @@ -685,10 +686,11 @@
html[data-bs-theme='light'] { background: var(--mono-white, var(--bs-body-bg, #fff)); color-scheme: light; }
`;

// Username colors by rating tier. Each color keeps at least 3.3:1 contrast on both
// the light and the dark background, so one palette is used on every page and
// theme instead of Bootstrap's link-* colors, which change with theme. Like
// Bootstrap, hover darkens the color by 20% and makes the underline opaque.
// Username colors by rating tier, plus violet for script admins. Each color keeps
// at least 3.3:1 contrast on both the light and the dark background, so one
// palette is used on every page and theme instead of Bootstrap's link-* colors,
// which change with theme. Like Bootstrap, hover darkens the color by 20% and
// makes the underline opaque.
const RatingColorCSS = `
a.xmoj-rating-red { color: #dc2f5a !important; text-decoration-color: rgba(220, 47, 90, 0.5) !important; }
a.xmoj-rating-red:hover, a.xmoj-rating-red:focus { color: #b02648 !important; text-decoration-color: #b02648 !important; }
Expand All @@ -702,6 +704,8 @@
a.xmoj-rating-cyan:hover, a.xmoj-rating-cyan:focus { color: #127a8d !important; text-decoration-color: #127a8d !important; }
a.xmoj-rating-gray { color: #78828c !important; text-decoration-color: rgba(120, 130, 140, 0.5) !important; }
a.xmoj-rating-gray:hover, a.xmoj-rating-gray:focus { color: #606870 !important; text-decoration-color: #606870 !important; }
a.xmoj-rating-admin { color: #a855f7 !important; text-decoration-color: rgba(168, 85, 247, 0.5) !important; }
a.xmoj-rating-admin:hover, a.xmoj-rating-admin:focus { color: #8644c6 !important; text-decoration-color: #8644c6 !important; }

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.

🟡 Medium · Admin names are harder to read

When the page is in dark theme and an admin username link is hovered or focused, a.xmoj-rating-admin:hover and a.xmoj-rating-admin:focus force #8644c6 against Bootstrap’s #212529 background, yielding about 3:1 contrast instead of the documented 3.3:1 minimum, so admin names are harder to read.

Use a hover and focus color that meets the documented contrast minimum in dark mode.

Prompt for AI agents
In `XMOJ.user.js` at line 707:

**Admin names are harder to read**

When the page is in dark theme and an admin username link is hovered or focused, `a.xmoj-rating-admin:hover` and `a.xmoj-rating-admin:focus` force `#8644c6` against Bootstrap’s `#212529` background, yielding about 3:1 contrast instead of the documented 3.3:1 minimum, so admin names are harder to read.

Use a hover and focus color that meets the documented contrast minimum in dark mode.

`;

// Both UI initializers use this link; loading only in legacy main() leaves /web
Expand Down Expand Up @@ -1640,13 +1644,14 @@
}
HTMLData += `" class="rounded me-2" style="width: 20px; height: 20px; ">`;
}
HTMLData += `<a href="${Href}${Username}" class="link-offset-2 link-underline-opacity-50 `
if (UtilityEnabled("Rating")) {
let IsScriptAdmin = AdminUserList.includes(Username);
HTMLData += `<a href="${Href}${Username}"${IsScriptAdmin ? ` title="脚本管理员"` : ""} class="link-offset-2 link-underline-opacity-50 `
if (IsScriptAdmin) {
// Violet is reserved for script admins and replaces the old badge, so it
// applies whether or not ratings are shown and never means a rating tier.
HTMLData += "xmoj-rating-admin";
} else if (UtilityEnabled("Rating")) {
let Rating = UserInfo.Rating;
// if(AdminUserList.includes(Username)){
// HTMLData += "link-fuchsia"
// }
// else
if (Rating >= 2400) {
HTMLData += "xmoj-rating-red";
} else if (Rating >= 2000) {
Expand All @@ -1665,9 +1670,6 @@
}
HTMLData += `\";"></a>`;
if (!Simple) {
if (AdminUserList.includes(Username)) {
HTMLData += `<span class="badge text-bg-danger ms-2">脚本管理员</span>`;
}
let BadgeInfo = await GetUserBadge(Username);
if (BadgeInfo.Content != "") {
HTMLData += `<span class="badge ms-2" style="background-color: ${BadgeInfo.BackgroundColor}; color: ${BadgeInfo.Color}">${BadgeInfo.Content}</span>`;
Expand Down Expand Up @@ -2839,7 +2841,7 @@
function CreateUserMenuItems() {
let Entries = [
["修改帐号", () => { location.href = "https://www.xmoj.tech/modify_user_info.php"; }],
["个人中心", () => { location.href = "https://www.xmoj.tech/userinfo.php?user=" + CurrentUsername; }],

Check failure

Code scanning / CodeQL

DOM text reinterpreted as HTML High

DOM text
is reinterpreted as HTML without escaping meta-characters.
["短消息", () => { location.href = "https://www.xmoj.tech/mail.php"; }],
["插件设置", () => { location.href = "https://www.xmoj.tech/index.php?ByUserScript=1"; }],
["插件更新日志", () => { location.href = "https://www.xmoj.tech/modify_user_info.php?ByUserScript=1"; }],
Expand Down Expand Up @@ -4849,41 +4851,41 @@
let CurrentJresultParam = params.get("jresult");
let CurrentJresult = checkNum(CurrentJresultParam) && -1 <= CurrentJresultParam && CurrentJresultParam <= 11 ? Number(CurrentJresultParam) : "-1";

if (document.querySelector("#simform") != null) document.querySelector("#simform").outerHTML = `<form id="simform" class="justify-content-center form-inline row g-2" action="status.php" method="get" style="padding-bottom: 7px;">
<input class="form-control" type="text" size="4" name="user_id" value="${CurrentUsername} "style="display: none;">
<div class="col-md-1">
<label for="problem_id" class="form-label">题目编号</label>
<input type="text" class="form-control" id="problem_id" name="problem_id" size="4">
</div>
<div class="col-md-1">
<label for="language" class="form-label">语言</label>
<select id="language" name="language" class="form-select">
<option value="-1">全部</option>
<option value="0">C</option>
<option value="1">C++</option>
<option value="2">Pascal</option>
</select>
</div><div class="col-md-1">
<label for="jresult" class="form-label">结果</label>
<select id="jresult" name="jresult" class="form-select">
<option value="-1">全部</option>
<option value="4">正确</option>
<option value="5">格式错误</option>
<option value="6">答案错误</option>
<option value="7">时间超限</option>
<option value="8">内存超限</option>
<option value="9">输出超限</option>
<option value="10">运行错误</option>
<option value="11">编译错误</option>
<option value="0">等待</option>
<option value="1">等待重判</option>
<option value="2">编译中</option>
<option value="3">运行并评判</option>
</select>
</div>
<div class="col-md-1">
<button type="submit" class="btn btn-primary">查找</button>
</div><div id="csrf"></div></form>`;

Check failure

Code scanning / CodeQL

DOM text reinterpreted as HTML High

DOM text
is reinterpreted as HTML without escaping meta-characters.

var selectElement = document.getElementById('problem_id');
selectElement.value = CurrentProblemId;
Expand Down Expand Up @@ -6245,6 +6247,14 @@
}
} else if (location.pathname == "/contest_video.php" || location.pathname == "/problem_video.php") {
let ScriptData = (document.querySelector("body > div > div.mt-3 > center > script") != null) ? document.querySelector("body > div > div.mt-3 > center > script").innerHTML : "";
let VideoHeading = document.querySelector("center h1, center h2, center h3");
if (VideoHeading != null && VideoHeading.innerText.trim() != "") {
document.title = "回放: " + VideoHeading.innerText.trim();
} else if (SearchParams.get("cid") != null) {
document.title = "比赛 " + Number(SearchParams.get("cid")) + " 回放";
} else {
document.title = "回放";
}
if (document.getElementById("J_prismPlayer0").innerHTML != "") {
document.getElementById("J_prismPlayer0").innerHTML = "";
if (player) {
Expand Down Expand Up @@ -8982,6 +8992,7 @@
const effectiveSrc = img.currentSrc || img.src;
if (!img.classList.contains("xmoj-image-preview") &&
!img.closest(".xmoj-image-modal") &&
!img.closest(".prism-player, [id^=\"J_prismPlayer\"]") && // video player controls (e.g. progress bar thumb)
effectiveSrc &&
!effectiveSrc.includes("gravatar") &&
!effectiveSrc.includes("cravatar")) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xmoj-script",
"version": "3.8.6",
"version": "3.8.8",
"description": "an improvement script for xmoj.tech",
"main": "AddonScript.js",
"scripts": {
Expand Down
Loading