版本比较
洛谷提交优化【暂不支持青题】
标题
增加 1 行删除 1 行
11洛谷提交优化洛谷提交优化【暂不支持青题】正文
增加 184 行删除 0 行
123456789101112163 行未改动全部展开176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359由 AI 辅助完成。
与[[工程] 洛谷修改提交记录方框背景](https://www.luogu.com.cn/article/xscqjzbk)一起使用效果更佳。
# V1.0
AC 题目时会有横幅。
:::info[源代码]
```// ==UserScript==163 行未改动全部展开
通过蓝/紫/黑题时会有烟花:

# V2.0
在 V1.0 的基础上,增加了 WA、TLE 等评测状态的横幅。
感谢 @[ZAR_Ferarri_F1_Team](https://www.luogu.com.cn/user/1375428) 提供的灵感。
:::info[源代码]
```// ==UserScript==// @name 洛谷提交状态优化// @namespace http://tampermonkey.net/// @version V2.0// @description 感谢 ZAR_Ferarri_F1_Team & Gemini 的贡献。// @author Otachi// @match *://*.luogu.com.cn/*// @require https://cdn.jsdelivr.net/npm/canvas-confetti@1.6.0/dist/confetti.browser.min.js// @grant none// ==/UserScript==
(function() { 'use strict';
// 难度定义 (仅用于 AC 时的装饰) const AIRSPACES = { 1: { name: "入门", color: "#FE4C61", rarity: "COMMON" }, 2: { name: "普及-", color: "#F39C11", rarity: "UNUSUAL" }, 3: { name: "普及/提高−", color: "#FFC116", rarity: "RARE" }, 4: { name: "普及+/提高", color: "#52C41A", rarity: "EPIC" }, 5: { name: "提高+/省选−", color: "#3498DB", rarity: "LEGENDARY" }, 6: { name: "省选/NOI−", color: "#9D3DCF", rarity: "MYTHIC" }, 7: { name: "NOI/NOI+/CTSC", color: "#0E1D69", rarity: "ULTRA" } };
// 核心:洛谷原色定义 const JUDGE_STATUS = { "AC": { text: "ACCEPTED", color: "#52C41A", bgColor: "#E8F5E9" }, "WA": { text: "WRONG ANSWER", color: "#E74C3C", bgColor: "#FDEDEC" }, "TLE": { text: "TIME LIMIT EXCEEDED", color: "#052242", bgColor: "#EBEDEF" }, "MLE": { text: "MEMORY LIMIT EXCEEDED", color: "#052242", bgColor: "#EBEDEF" }, "RE": { text: "RUNTIME ERROR", color: "#9D3DCF", bgColor: "#F5EEF8" }, "CE": { text: "COMPILE ERROR", color: "#F39C11", bgColor: "#FEF5E7" }, "OLE": { text: "OUTPUT LIMIT EXCEEDED", color: "#052242", bgColor: "#EBEDEF" }, "UKE": { text: "UNKNOWN ERROR", color: "#0E1D69", bgColor: "#EAECEE" } };
const TESTCASE_STATUS_MAP = { 3: "OLE", 4: "MLE", 5: "TLE", 6: "WA", 7: "RE", 12: "AC" }; let lastRecordId = "";
function launchFireworks(color) { if (typeof confetti !== 'function') return; const duration = 2000, end = Date.now() + duration; (function frame() { confetti({ particleCount: 3, angle: 60, spread: 55, origin: { x: 0, y: 0.8 }, colors: [color, '#ffffff'] }); confetti({ particleCount: 3, angle: 120, spread: 55, origin: { x: 1, y: 0.8 }, colors: [color, '#ffffff'] }); if (Date.now() < end) requestAnimationFrame(frame); }()); }
function closeBanner(banner) { if (!banner || banner.classList.contains('leaving')) return; banner.classList.remove('glow-pulse'); banner.classList.add('leaving'); banner.style.transform = 'translateY(-140px)'; banner.style.opacity = '0'; setTimeout(() => { if (banner.parentNode) banner.remove(); }, 600); }
function getJudgeStatus(record) { const sc = Number(record.status); if (sc === 0) return "WAIT"; if (sc === 1) return "JUDGE"; if (sc === 2) return "CE"; const detail = record.detail; if (!detail || !detail.judgeResult) return sc === 12 ? "AC" : "UKE"; const subtasks = detail.judgeResult.subtasks || []; let firstErr = null; Object.values(subtasks).forEach(sub => { Object.values(sub.testCases || {}).forEach(tc => { if (tc.status !== 12 && !firstErr) firstErr = tc.status; }); }); return firstErr ? (TESTCASE_STATUS_MAP[firstErr] || "WA") : "AC"; }
function showAchievementBanner(target, pid, statusKey) { const old = document.getElementById('florr-achievement-banner'); if (old) old.remove();
const banner = document.createElement('div'); banner.id = 'florr-achievement-banner';
const info = JUDGE_STATUS[statusKey] || JUDGE_STATUS["UKE"]; const isAC = statusKey === "AC"; const color = isAC ? target.color : info.color; // AC用难度色,其余用原色
banner.style.cssText = ` position: fixed; top: 0; left: 0; width: 100%; height: 140px; z-index: 1000000; display: flex; align-items: center; justify-content: center; background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.98) 20%, rgba(255,255,255,0.98) 80%, transparent 100%); border-bottom: 8px solid ${color}; box-shadow: 0 15px 50px rgba(0,0,0,0.15); cursor: pointer; user-select: none; transform: translateY(-100%); opacity: 0; transition: transform 0.6s cubic-bezier(0.18, 0.89, 0.32, 1.28), opacity 0.4s ease; `;
const isHigh = ["LEGENDARY", "MYTHIC", "ULTRA"].includes(target.rarity); banner.className = (isAC && isHigh) ? 'glow-pulse' : '';
const actionText = isAC ? 'Destroyed Target' : 'Destroyed by Target'; const missionSub = isAC ? 'MISSION COMPLETE' : 'MISSION FAILED';
banner.innerHTML = ` <div style="display: flex; align-items: center; gap: 50px; width: 95%; max-width: 1300px; justify-content: center;"> <div style="flex-shrink: 0; width: 240px; height: 100px; border-radius: 20px; border: 6px solid ${color}; background: ${info.bgColor}; display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 900; color: ${color}; text-align: center; box-shadow: inset 0 0 20px ${color}22;"> ${isAC ? target.name : statusKey} </div> <div style="text-align: left; font-family: 'Arial Black', sans-serif; min-width: 450px;"> <div style="font-size: 16px; font-weight: 900; color: #777; letter-spacing: 4px; margin-bottom: 4px;"> ${missionSub} </div> <div style="font-size: 45px; font-weight: 900; color: ${color}; line-height: 1.1;"> ${actionText} <span style="font-family: 'Courier New', Courier, monospace; letter-spacing: -1px;">${pid}</span> </div> <div style="font-size: 18px; color: #aaa; margin-top: 4px; letter-spacing: 2px;"> RANK: ${target.rarity} </div> </div> </div>`;
document.body.appendChild(banner); banner.onclick = () => closeBanner(banner); setTimeout(() => { banner.style.transform = 'translateY(0)'; banner.style.opacity = '1'; }, 100);
// 动态消失时间:CE短,AC长 let duration = isAC ? 7000 : 5000; if (statusKey === "CE") duration = 3000; setTimeout(() => closeBanner(banner), duration); }
function lockAndFire() { try { const feData = window._feInjection || window._feConfig; if (!feData || !feData.currentData) return; const record = feData.currentData.record; if (!record || record.id === lastRecordId) return;
if ((feData.currentUser?.uid || feData.currentUser?.id) == (record.user.uid || record.user.id)) { const status = getJudgeStatus(record); if (status === "WAIT" || status === "JUDGE") return;
lastRecordId = record.id; const target = AIRSPACES[record.problem.difficulty] || AIRSPACES[1]; showAchievementBanner(target, record.problem.pid, status); if (status === "AC" && record.problem.difficulty >= 5) launchFireworks(target.color); } } catch (e) {} }
const style = document.createElement('style'); style.innerHTML = ` .glow-pulse { animation: pulse 2s infinite ease-in-out; } @keyframes pulse { 0% { box-shadow: 0 15px 50px rgba(0,0,0,0.15); } 50% { box-shadow: 0 15px 70px rgba(52, 152, 219, 0.4); border-bottom-color: #fff; } 100% { box-shadow: 0 15px 50px rgba(0,0,0,0.15); } } .leaving { pointer-events: none; transition: transform 0.5s cubic-bezier(0.55, 0, 1, 0.45), opacity 0.4s ease !important; } `; document.head.appendChild(style); setInterval(lockAndFire, 1000);})();```
:::