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
11 changes: 11 additions & 0 deletions Update.json
Original file line number Diff line number Diff line change
Expand Up @@ -3649,6 +3649,17 @@
}
],
"Notes": "修复了 MonochromeUI / NewBootstrap 新界面在深色模式下加载时出现的白色闪烁(FOUC/CLS)问题。"
},
"3.5.4": {
"UpdateDate": 1785114353055,
"Prerelease": true,
"UpdateContents": [
{
"PR": 997,
"Description": "fix: pin Monaco to 0.52.2 to stop intermittent editor load failures"
}
],
"Notes": "修复了提交代码页面上 Monaco 编辑器有时无法加载、退化为纯文本框的问题(Monaco 0.53.0 的上游 bug)。"
}
}
}
19 changes: 17 additions & 2 deletions XMOJ.user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==UserScript==
// @name XMOJ
// @version 3.5.3
// @version 3.5.4
// @description XMOJ增强脚本
// @author @XMOJ-Script-dev, @langningchen and the community
// @namespace https://github/langningchen
Expand Down Expand Up @@ -551,7 +551,11 @@ let _earlyObs = null;
})();

const CaptchaSiteKey = "0x4AAAAAAALBT58IhyDViNmv";
const MonacoCDN = "https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.53.0/min/vs";
// 0.53.0 leaks its minified helper variables (m, r, o, ...) into the global scope from every
// chunk file, so whichever chunk happens to be evaluated last clobbers the others and the
// editor randomly fails to load (microsoft/monaco-editor#5015). 0.52.2 ships a single bundle
// and is not affected. cdnjs has no fixed release newer than 0.53.0 yet.
const MonacoCDN = "https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.52.2/min/vs";
const AdminUserList = ["zhuchenrui2", "shanwenxiao", "chenlangning", "admin"];

// Pre-declared so that closures defined before the async init block can reference them
Expand Down Expand Up @@ -751,8 +755,19 @@ let GetUserBadge = async (Username) => {
}
}
};
let MonacoLoadPromise = null;
async function ensureMonaco() {
if (typeof monaco !== 'undefined') return;
// Callers can overlap (submit page editor, merge view, freopen snippets). Without this guard
// each of them appends its own loader.js, and the second loader resets the AMD registry while
// the first one is still resolving modules.
if (MonacoLoadPromise === null) {
MonacoLoadPromise = loadMonaco();
MonacoLoadPromise.catch(() => { MonacoLoadPromise = null; });
}
return MonacoLoadPromise;
}
async function loadMonaco() {
const loaderUrl = MonacoCDN + '/loader.js';
if (typeof require === 'undefined' || typeof require.config === 'undefined') {
await new Promise((resolve, reject) => {
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.5.3",
"version": "3.5.4",
"description": "an improvement script for xmoj.tech",
"main": "AddonScript.js",
"scripts": {
Expand Down
Loading