xmoj-script 1.2.2 → 1.2.4
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 +36 -6
- package/package.json +1 -1
package/Update.json
CHANGED
@@ -1688,6 +1688,28 @@
|
|
1688
1688
|
}
|
1689
1689
|
],
|
1690
1690
|
"Notes": "No release notes were provided for this release."
|
1691
|
+
},
|
1692
|
+
"1.2.3": {
|
1693
|
+
"UpdateDate": 1722003346568,
|
1694
|
+
"Prerelease": true,
|
1695
|
+
"UpdateContents": [
|
1696
|
+
{
|
1697
|
+
"PR": 563,
|
1698
|
+
"Description": "fix #562"
|
1699
|
+
}
|
1700
|
+
],
|
1701
|
+
"Notes": "No release notes were provided for this release."
|
1702
|
+
},
|
1703
|
+
"1.2.4": {
|
1704
|
+
"UpdateDate": 1722040221117,
|
1705
|
+
"Prerelease": true,
|
1706
|
+
"UpdateContents": [
|
1707
|
+
{
|
1708
|
+
"PR": 565,
|
1709
|
+
"Description": "短消息增加图床支持"
|
1710
|
+
}
|
1711
|
+
],
|
1712
|
+
"Notes": "No release notes were provided for this release."
|
1691
1713
|
}
|
1692
1714
|
}
|
1693
1715
|
}
|
package/XMOJ.user.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
// ==UserScript==
|
2
2
|
// @name XMOJ
|
3
|
-
// @version 1.2.
|
3
|
+
// @version 1.2.4
|
4
4
|
// @description XMOJ增强脚本
|
5
5
|
// @author @XMOJ-Script-dev, @langningchen and the community
|
6
6
|
// @namespace https://github/langningchen
|
@@ -3859,6 +3859,35 @@ int main()
|
|
3859
3859
|
Content.addEventListener("input", () => {
|
3860
3860
|
Content.classList.remove("is-invalid");
|
3861
3861
|
});
|
3862
|
+
Content.addEventListener("paste", (EventData) => {
|
3863
|
+
let Items = EventData.clipboardData.items;
|
3864
|
+
if (Items.length !== 0) {
|
3865
|
+
for (let i = 0; i < Items.length; i++) {
|
3866
|
+
if (Items[i].type.indexOf("image") != -1) {
|
3867
|
+
let Reader = new FileReader();
|
3868
|
+
Reader.readAsDataURL(Items[i].getAsFile());
|
3869
|
+
Reader.onload = () => {
|
3870
|
+
let Before = Content.value.substring(0, Content.selectionStart);
|
3871
|
+
let After = Content.value.substring(Content.selectionEnd, Content.value.length);
|
3872
|
+
const UploadMessage = "![正在上传图片...]()";
|
3873
|
+
Content.value = Before + UploadMessage + After;
|
3874
|
+
Content.dispatchEvent(new Event("input"));
|
3875
|
+
RequestAPI("UploadImage", {
|
3876
|
+
"Image": Reader.result
|
3877
|
+
}, (ResponseData) => {
|
3878
|
+
if (ResponseData.Success) {
|
3879
|
+
Content.value = Before + `` + After;
|
3880
|
+
Content.dispatchEvent(new Event("input"));
|
3881
|
+
} else {
|
3882
|
+
Content.value = Before + `![上传失败!]()` + After;
|
3883
|
+
Content.dispatchEvent(new Event("input"));
|
3884
|
+
}
|
3885
|
+
});
|
3886
|
+
};
|
3887
|
+
}
|
3888
|
+
}
|
3889
|
+
}
|
3890
|
+
});
|
3862
3891
|
Content.addEventListener("keydown", (Event) => {
|
3863
3892
|
if (Event.keyCode == 13) {
|
3864
3893
|
Send.click();
|
@@ -3895,6 +3924,7 @@ int main()
|
|
3895
3924
|
Discussion.classList.add("active");
|
3896
3925
|
if (location.pathname == "/discuss3/discuss.php") {
|
3897
3926
|
let ProblemID = parseInt(SearchParams.get("pid"));
|
3927
|
+
let BoardID = parseInt(SearchParams.get("bid"));
|
3898
3928
|
let Page = Number(SearchParams.get("page")) || 1;
|
3899
3929
|
document.querySelector("body > div > div").innerHTML = `<h3>讨论列表${(isNaN(ProblemID) ? "" : ` - 题目` + ProblemID)}</h3>
|
3900
3930
|
<button id="NewPost" type="button" class="btn btn-primary">发布新讨论</button>
|
@@ -3954,11 +3984,11 @@ int main()
|
|
3954
3984
|
if (ResponseData.Success == true) {
|
3955
3985
|
ErrorElement.style.display = "none";
|
3956
3986
|
if (!Silent) {
|
3957
|
-
DiscussPagination.children[0].children[0].href = "https://www.xmoj.tech/discuss3/discuss.php?" + (isNaN(ProblemID) ? "" : "pid=" + ProblemID + "&") + "page=1";
|
3958
|
-
DiscussPagination.children[1].children[0].href = "https://www.xmoj.tech/discuss3/discuss.php?" + (isNaN(ProblemID) ? "" : "pid=" + ProblemID + "&") + "page=" + (Page - 1);
|
3959
|
-
DiscussPagination.children[2].children[0].href = "https://www.xmoj.tech/discuss3/discuss.php?" + (isNaN(ProblemID) ? "" : "pid=" + ProblemID + "&") + "page=" + Page;
|
3960
|
-
DiscussPagination.children[3].children[0].href = "https://www.xmoj.tech/discuss3/discuss.php?" + (isNaN(ProblemID) ? "" : "pid=" + ProblemID + "&") + "page=" + (Page + 1);
|
3961
|
-
DiscussPagination.children[4].children[0].href = "https://www.xmoj.tech/discuss3/discuss.php?" + (isNaN(ProblemID) ? "" : "pid=" + ProblemID + "&") + "page=" + ResponseData.Data.PageCount;
|
3987
|
+
DiscussPagination.children[0].children[0].href = "https://www.xmoj.tech/discuss3/discuss.php?" + (isNaN(ProblemID) ? "" : "pid=" + ProblemID + "&") + (isNaN(BoardID) ? "" : "bid=" + BoardID + "&") + "page=1";
|
3988
|
+
DiscussPagination.children[1].children[0].href = "https://www.xmoj.tech/discuss3/discuss.php?" + (isNaN(ProblemID) ? "" : "pid=" + ProblemID + "&") + (isNaN(BoardID) ? "" : "bid=" + BoardID + "&") + "page=" + (Page - 1);
|
3989
|
+
DiscussPagination.children[2].children[0].href = "https://www.xmoj.tech/discuss3/discuss.php?" + (isNaN(ProblemID) ? "" : "pid=" + ProblemID + "&") + (isNaN(BoardID) ? "" : "bid=" + BoardID + "&") + "page=" + Page;
|
3990
|
+
DiscussPagination.children[3].children[0].href = "https://www.xmoj.tech/discuss3/discuss.php?" + (isNaN(ProblemID) ? "" : "pid=" + ProblemID + "&") + (isNaN(BoardID) ? "" : "bid=" + BoardID + "&") + "page=" + (Page + 1);
|
3991
|
+
DiscussPagination.children[4].children[0].href = "https://www.xmoj.tech/discuss3/discuss.php?" + (isNaN(ProblemID) ? "" : "pid=" + ProblemID + "&") + (isNaN(BoardID) ? "" : "bid=" + BoardID + "&") + "page=" + ResponseData.Data.PageCount;
|
3962
3992
|
if (Page <= 1) {
|
3963
3993
|
DiscussPagination.children[0].classList.add("disabled");
|
3964
3994
|
DiscussPagination.children[1].remove();
|