xmoj-script 1.1.58 → 1.1.60
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 +22 -0
- package/XMOJ.user.js +70 -27
- package/package.json +1 -1
package/Update.json
CHANGED
@@ -1469,6 +1469,28 @@
|
|
1469
1469
|
}
|
1470
1470
|
],
|
1471
1471
|
"Notes": "No release notes were provided for this release."
|
1472
|
+
},
|
1473
|
+
"1.1.59": {
|
1474
|
+
"UpdateDate": 1713676517652,
|
1475
|
+
"Prerelease": true,
|
1476
|
+
"UpdateContents": [
|
1477
|
+
{
|
1478
|
+
"PR": 515,
|
1479
|
+
"Description": "允许管理在用户页管理badge并在修改badge后清除缓存"
|
1480
|
+
}
|
1481
|
+
],
|
1482
|
+
"Notes": "No release notes were provided for this release."
|
1483
|
+
},
|
1484
|
+
"1.1.60": {
|
1485
|
+
"UpdateDate": 1713682768316,
|
1486
|
+
"Prerelease": true,
|
1487
|
+
"UpdateContents": [
|
1488
|
+
{
|
1489
|
+
"PR": 516,
|
1490
|
+
"Description": "revert #514"
|
1491
|
+
}
|
1492
|
+
],
|
1493
|
+
"Notes": "No release notes were provided for this release."
|
1472
1494
|
}
|
1473
1495
|
}
|
1474
1496
|
}
|
package/XMOJ.user.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
// ==UserScript==
|
2
2
|
// @name XMOJ
|
3
|
-
// @version 1.1.
|
3
|
+
// @version 1.1.60
|
4
4
|
// @description XMOJ增强脚本
|
5
5
|
// @author @XMOJ-Script-dev, @langningchen and the community
|
6
6
|
// @namespace https://github/langningchen
|
@@ -2681,7 +2681,15 @@ async function main() {
|
|
2681
2681
|
BadgeContent.value = Response.Data.Content;
|
2682
2682
|
BadgeBackgroundColor.value = Response.Data.BackgroundColor;
|
2683
2683
|
BadgeColor.value = Response.Data.Color;
|
2684
|
-
|
2684
|
+
let Temp = [];
|
2685
|
+
for (let i = 0; i < localStorage.length; i++) {
|
2686
|
+
if (localStorage.key(i).startsWith("UserScript-User-" + CurrentUsername + "-Badge-")) {
|
2687
|
+
Temp.push(localStorage.key(i));
|
2688
|
+
}
|
2689
|
+
}
|
2690
|
+
for (let i = 0; i < Temp.length; i++) {
|
2691
|
+
localStorage.removeItem(Temp[i]);
|
2692
|
+
}
|
2685
2693
|
}
|
2686
2694
|
});
|
2687
2695
|
ModifyInfo.addEventListener("click", async () => {
|
@@ -2855,7 +2863,63 @@ async function main() {
|
|
2855
2863
|
let lastOnlineElement = document.createElement('div');
|
2856
2864
|
lastOnlineElement.innerHTML = "最后在线:加载中...<br>";
|
2857
2865
|
UserInfoElement.appendChild(lastOnlineElement);
|
2858
|
-
|
2866
|
+
let BadgeInfo = await GetUserBadge(UserID);
|
2867
|
+
if (IsAdmin) {
|
2868
|
+
if (BadgeInfo.Content !== "") {
|
2869
|
+
let DeleteBadgeButton = document.createElement("button");
|
2870
|
+
DeleteBadgeButton.className = "btn btn-outline-danger btn-sm";
|
2871
|
+
DeleteBadgeButton.innerText = "删除标签";
|
2872
|
+
DeleteBadgeButton.addEventListener("click", async () => {
|
2873
|
+
if (confirm("您确定要删除此标签吗?")) {
|
2874
|
+
RequestAPI("DeleteBadge", {
|
2875
|
+
"UserID": UserID
|
2876
|
+
}, (Response) => {
|
2877
|
+
if (UtilityEnabled("DebugMode")) console.log(Response);
|
2878
|
+
if (Response.Success) {
|
2879
|
+
let Temp = [];
|
2880
|
+
for (let i = 0; i < localStorage.length; i++) {
|
2881
|
+
if (localStorage.key(i).startsWith("UserScript-User-" + UserID + "-Badge-")) {
|
2882
|
+
Temp.push(localStorage.key(i));
|
2883
|
+
}
|
2884
|
+
}
|
2885
|
+
for (let i = 0; i < Temp.length; i++) {
|
2886
|
+
localStorage.removeItem(Temp[i]);
|
2887
|
+
}
|
2888
|
+
window.location.reload();
|
2889
|
+
} else {
|
2890
|
+
alert(Response.Message);
|
2891
|
+
}
|
2892
|
+
});
|
2893
|
+
}
|
2894
|
+
});
|
2895
|
+
UserInfoElement.appendChild(DeleteBadgeButton);
|
2896
|
+
} else {
|
2897
|
+
let AddBadgeButton = document.createElement("button");
|
2898
|
+
AddBadgeButton.className = "btn btn-outline-primary btn-sm";
|
2899
|
+
AddBadgeButton.innerText = "添加标签";
|
2900
|
+
AddBadgeButton.addEventListener("click", async () => {
|
2901
|
+
RequestAPI("NewBadge", {
|
2902
|
+
"UserID": UserID
|
2903
|
+
}, (Response) => {
|
2904
|
+
if (Response.Success) {
|
2905
|
+
let Temp = [];
|
2906
|
+
for (let i = 0; i < localStorage.length; i++) {
|
2907
|
+
if (localStorage.key(i).startsWith("UserScript-User-" + UserID + "-Badge-")) {
|
2908
|
+
Temp.push(localStorage.key(i));
|
2909
|
+
}
|
2910
|
+
}
|
2911
|
+
for (let i = 0; i < Temp.length; i++) {
|
2912
|
+
localStorage.removeItem(Temp[i]);
|
2913
|
+
}
|
2914
|
+
window.location.reload();
|
2915
|
+
} else {
|
2916
|
+
alert(Response.Message);
|
2917
|
+
}
|
2918
|
+
});
|
2919
|
+
});
|
2920
|
+
UserInfoElement.appendChild(AddBadgeButton);
|
2921
|
+
}
|
2922
|
+
}
|
2859
2923
|
RequestAPI("LastOnline", {"Username": UserID}, (result) => {
|
2860
2924
|
if (result.Success) {
|
2861
2925
|
if (UtilityEnabled("DebugMode")) {
|
@@ -3811,23 +3875,8 @@ int main()
|
|
3811
3875
|
if (location.pathname == "/discuss3/discuss.php") {
|
3812
3876
|
let ProblemID = parseInt(SearchParams.get("pid"));
|
3813
3877
|
let Page = Number(SearchParams.get("page")) || 1;
|
3814
|
-
document.querySelector("body > div > div").innerHTML =
|
3815
|
-
|
3816
|
-
<div class="col-md-5">
|
3817
|
-
<form action="discuss.php" >
|
3818
|
-
<div style="text-align:right">
|
3819
|
-
<button id="NewPost" type="button" class="btn btn-primary">发布新讨论</button>
|
3820
|
-
</div>
|
3821
|
-
</form>
|
3822
|
-
</div>
|
3823
|
-
<div class="col-md-3" style="display: inline">
|
3824
|
-
<form action="thread.php" class="input-group">
|
3825
|
-
<input class="form-control" type="number" name="tid" placeholder="讨论编号" min="1">
|
3826
|
-
<button class="btn btn-outline-secondary" type="submit">跳转</button>
|
3827
|
-
</form>
|
3828
|
-
</div style="display: inline">
|
3829
|
-
</div>
|
3830
|
-
<h><br></h>
|
3878
|
+
document.querySelector("body > div > div").innerHTML = `<h3>讨论列表${(isNaN(ProblemID) ? "" : ` - 题目` + ProblemID)}</h3>
|
3879
|
+
<button id="NewPost" type="button" class="btn btn-primary">发布新讨论</button>
|
3831
3880
|
<nav>
|
3832
3881
|
<ul class="pagination justify-content-center" id="DiscussPagination">
|
3833
3882
|
<li class="page-item"><a class="page-link" href="#"><span>«</span></a></li>
|
@@ -3883,7 +3932,7 @@ int main()
|
|
3883
3932
|
}, async (ResponseData) => {
|
3884
3933
|
if (ResponseData.Success == true) {
|
3885
3934
|
ErrorElement.style.display = "none";
|
3886
|
-
if(!Silent) {
|
3935
|
+
if (!Silent) {
|
3887
3936
|
DiscussPagination.children[0].children[0].href = "https://www.xmoj.tech/discuss3/discuss.php?" + (isNaN(ProblemID) ? "" : "pid=" + ProblemID + "&") + "page=1";
|
3888
3937
|
DiscussPagination.children[1].children[0].href = "https://www.xmoj.tech/discuss3/discuss.php?" + (isNaN(ProblemID) ? "" : "pid=" + ProblemID + "&") + "page=" + (Page - 1);
|
3889
3938
|
DiscussPagination.children[2].children[0].href = "https://www.xmoj.tech/discuss3/discuss.php?" + (isNaN(ProblemID) ? "" : "pid=" + ProblemID + "&") + "page=" + Page;
|
@@ -3902,7 +3951,6 @@ int main()
|
|
3902
3951
|
PostList.children[1].innerHTML = "";
|
3903
3952
|
if (Posts.length == 0) {
|
3904
3953
|
PostList.children[1].innerHTML = `<tr><td colspan="7">暂无数据</td></tr>`;
|
3905
|
-
location.href = "https://www.xmoj.tech/discuss3/discuss.php";
|
3906
3954
|
}
|
3907
3955
|
for (let i = 0; i < Posts.length; i++) {
|
3908
3956
|
let Row = document.createElement("tr");
|
@@ -3940,11 +3988,6 @@ int main()
|
|
3940
3988
|
let LastReplyTimeCell = document.createElement("td");
|
3941
3989
|
Row.appendChild(LastReplyTimeCell);
|
3942
3990
|
LastReplyTimeCell.innerHTML = GetRelativeTime(Posts[i].LastReplyTime);
|
3943
|
-
if (Posts[i].PostID == 1) {
|
3944
|
-
DiscussPagination.children[DiscussPagination.children.length - 1].classList.add("disabled");
|
3945
|
-
DiscussPagination.children[DiscussPagination.children.length - 2].remove();
|
3946
|
-
break;
|
3947
|
-
}
|
3948
3991
|
}
|
3949
3992
|
} else {
|
3950
3993
|
ErrorElement.innerText = ResponseData.Message;
|