xmoj-script 2.0.0 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Update.json +33 -0
- package/XMOJ.user.js +45 -14
- package/package.json +1 -1
package/Update.json
CHANGED
@@ -2958,6 +2958,39 @@
|
|
2958
2958
|
}
|
2959
2959
|
],
|
2960
2960
|
"Notes": "No release notes were provided for this release."
|
2961
|
+
},
|
2962
|
+
"2.1.0": {
|
2963
|
+
"UpdateDate": 1754724455081,
|
2964
|
+
"Prerelease": false,
|
2965
|
+
"UpdateContents": [
|
2966
|
+
{
|
2967
|
+
"PR": 826,
|
2968
|
+
"Description": "修复更新"
|
2969
|
+
}
|
2970
|
+
],
|
2971
|
+
"Notes": "No release notes were provided for this release."
|
2972
|
+
},
|
2973
|
+
"2.1.1": {
|
2974
|
+
"UpdateDate": 1754911555185,
|
2975
|
+
"Prerelease": true,
|
2976
|
+
"UpdateContents": [
|
2977
|
+
{
|
2978
|
+
"PR": 829,
|
2979
|
+
"Description": "Update diff-match-patch library source URL"
|
2980
|
+
}
|
2981
|
+
],
|
2982
|
+
"Notes": "No release notes were provided for this release."
|
2983
|
+
},
|
2984
|
+
"2.1.2": {
|
2985
|
+
"UpdateDate": 1755589063111,
|
2986
|
+
"Prerelease": true,
|
2987
|
+
"UpdateContents": [
|
2988
|
+
{
|
2989
|
+
"PR": 834,
|
2990
|
+
"Description": "feat: use credential management api"
|
2991
|
+
}
|
2992
|
+
],
|
2993
|
+
"Notes": "No release notes were provided for this release."
|
2961
2994
|
}
|
2962
2995
|
}
|
2963
2996
|
}
|
package/XMOJ.user.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
// ==UserScript==
|
2
2
|
// @name XMOJ
|
3
|
-
// @version 2.
|
3
|
+
// @version 2.1.2
|
4
4
|
// @description XMOJ增强脚本
|
5
5
|
// @author @XMOJ-Script-dev, @langningchen and the community
|
6
6
|
// @namespace https://github/langningchen
|
@@ -10,7 +10,7 @@
|
|
10
10
|
// @require https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/codemirror.min.js
|
11
11
|
// @require https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/mode/clike/clike.min.js
|
12
12
|
// @require https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/addon/merge/merge.min.js
|
13
|
-
// @require https://
|
13
|
+
// @require https://gitee.com/mirrors_google/diff-match-patch/raw/master/javascript/diff_match_patch_uncompressed.js
|
14
14
|
// @require https://cdnjs.cloudflare.com/ajax/libs/dompurify/3.0.2/purify.min.js
|
15
15
|
// @require https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.5/FileSaver.min.js
|
16
16
|
// @require https://cdnjs.cloudflare.com/ajax/libs/marked/4.3.0/marked.min.js
|
@@ -441,6 +441,35 @@ let UtilityEnabled = (Name) => {
|
|
441
441
|
}
|
442
442
|
}
|
443
443
|
};
|
444
|
+
let storeCredential = async (username, password) => {
|
445
|
+
if ('credentials' in navigator && window.PasswordCredential) {
|
446
|
+
try {
|
447
|
+
const credential = new PasswordCredential({ id: username, password: password });
|
448
|
+
await navigator.credentials.store(credential);
|
449
|
+
} catch (e) {
|
450
|
+
console.error(e);
|
451
|
+
}
|
452
|
+
}
|
453
|
+
};
|
454
|
+
let getCredential = async () => {
|
455
|
+
if ('credentials' in navigator && window.PasswordCredential) {
|
456
|
+
try {
|
457
|
+
return await navigator.credentials.get({ password: true, mediation: 'optional' });
|
458
|
+
} catch (e) {
|
459
|
+
console.error(e);
|
460
|
+
}
|
461
|
+
}
|
462
|
+
return null;
|
463
|
+
};
|
464
|
+
let clearCredential = async () => {
|
465
|
+
if ('credentials' in navigator && window.PasswordCredential) {
|
466
|
+
try {
|
467
|
+
await navigator.credentials.preventSilentAccess();
|
468
|
+
} catch (e) {
|
469
|
+
console.error(e);
|
470
|
+
}
|
471
|
+
}
|
472
|
+
};
|
444
473
|
let RequestAPI = (Action, Data, CallBack) => {
|
445
474
|
try {
|
446
475
|
let Session = "";
|
@@ -962,8 +991,7 @@ async function main() {
|
|
962
991
|
location.href = "https://www.xmoj.tech/modifypage.php?ByUserScript=1";
|
963
992
|
});
|
964
993
|
PopupUL.children[5].addEventListener("click", () => {
|
965
|
-
|
966
|
-
localStorage.removeItem("UserScript-Password");
|
994
|
+
clearCredential();
|
967
995
|
document.cookie = "PHPSESSID=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/"; //This is how you remove a cookie?
|
968
996
|
location.href = "https://www.xmoj.tech/logout.php";
|
969
997
|
});
|
@@ -3213,12 +3241,11 @@ async function main() {
|
|
3213
3241
|
.then((Response) => {
|
3214
3242
|
return Response.text();
|
3215
3243
|
})
|
3216
|
-
.then((Response) => {
|
3244
|
+
.then(async (Response) => {
|
3217
3245
|
if (UtilityEnabled("LoginFailed")) {
|
3218
3246
|
if (Response.indexOf("history.go(-2);") != -1) {
|
3219
3247
|
if (UtilityEnabled("SavePassword")) {
|
3220
|
-
|
3221
|
-
localStorage.setItem("UserScript-Password", Password);
|
3248
|
+
await storeCredential(Username, Password);
|
3222
3249
|
}
|
3223
3250
|
let NewPage = localStorage.getItem("UserScript-LastPage");
|
3224
3251
|
if (NewPage == null) {
|
@@ -3227,8 +3254,7 @@ async function main() {
|
|
3227
3254
|
location.href = NewPage;
|
3228
3255
|
} else {
|
3229
3256
|
if (UtilityEnabled("SavePassword")) {
|
3230
|
-
|
3231
|
-
localStorage.removeItem("UserScript-Password");
|
3257
|
+
clearCredential();
|
3232
3258
|
}
|
3233
3259
|
Response = Response.substring(Response.indexOf("alert('") + 7);
|
3234
3260
|
Response = Response.substring(0, Response.indexOf("');"));
|
@@ -3244,10 +3270,15 @@ async function main() {
|
|
3244
3270
|
});
|
3245
3271
|
}
|
3246
3272
|
});
|
3247
|
-
if (UtilityEnabled("SavePassword")
|
3248
|
-
|
3249
|
-
|
3250
|
-
|
3273
|
+
if (UtilityEnabled("SavePassword")) {
|
3274
|
+
(async () => {
|
3275
|
+
let Credential = await getCredential();
|
3276
|
+
if (Credential) {
|
3277
|
+
document.querySelector("#login > div:nth-child(1) > div > input").value = Credential.id;
|
3278
|
+
document.querySelector("#login > div:nth-child(2) > div > input").value = Credential.password;
|
3279
|
+
LoginButton.click();
|
3280
|
+
}
|
3281
|
+
})();
|
3251
3282
|
}
|
3252
3283
|
} else if (location.pathname == "/contest_video.php" || location.pathname == "/problem_video.php") {
|
3253
3284
|
let ScriptData = document.querySelector("body > div > div.mt-3 > center > script").innerHTML;
|
@@ -3814,7 +3845,7 @@ int main()
|
|
3814
3845
|
AddUser.disabled = true;
|
3815
3846
|
RequestAPI("SendMail", {
|
3816
3847
|
"ToUser": String(UsernameData),
|
3817
|
-
"Content": String("您好,我是" +
|
3848
|
+
"Content": String("您好,我是" + CurrentUsername)
|
3818
3849
|
}, (ResponseData) => {
|
3819
3850
|
AddUser.children[0].style.display = "none";
|
3820
3851
|
AddUser.disabled = false;
|