Skip to content

Commit

Permalink
Merge pull request #581 from XMOJ-Script-dev/boomzero/copymd
Browse files Browse the repository at this point in the history
fix copymd
  • Loading branch information
boomzero authored Aug 1, 2024
2 parents ad939ec + aedd666 commit bc034d4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
11 changes: 11 additions & 0 deletions Update.json
Original file line number Diff line number Diff line change
Expand Up @@ -1848,6 +1848,17 @@
}
],
"Notes": "No release notes were provided for this release."
},
"1.2.15": {
"UpdateDate": 1722472465539,
"Prerelease": true,
"UpdateContents": [
{
"PR": 581,
"Description": "fix copymd"
}
],
"Notes": "No release notes were provided for this release."
}
}
}
14 changes: 8 additions & 6 deletions XMOJ.user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==UserScript==
// @name XMOJ
// @version 1.2.14
// @version 1.2.15
// @description XMOJ增强脚本
// @author @XMOJ-Script-dev, @langningchen and the community
// @namespace https://github/langningchen
Expand Down Expand Up @@ -1295,17 +1295,19 @@ async function main() {
return Response.text();
}).then((Response) => {
let ParsedDocument = new DOMParser().parseFromString(Response, "text/html");
let Temp = ParsedDocument.querySelectorAll(".cnt-row");
let Temp = ParsedDocument.querySelectorAll(".cnt-row-body");
if (UtilityEnabled("DebugMode"))
console.log(Temp);
for (let i = 0; i < Temp.length; i++) {
if (Temp[i].children[1].children[0].className == "content") {
if (Temp[i].children[0].className === "content lang_cn") {
let CopyMDButton = document.createElement("button");
CopyMDButton.className = "btn btn-sm btn-outline-secondary copy-btn";
CopyMDButton.innerText = "复制";
CopyMDButton.style.marginLeft = "10px";
CopyMDButton.type = "button";
document.querySelectorAll(".cnt-row")[i].children[0].appendChild(CopyMDButton);
document.querySelectorAll(".cnt-row-head.title")[i].appendChild(CopyMDButton);
CopyMDButton.addEventListener("click", () => {
GM_setClipboard(Temp[i].children[1].children[0].innerText.trim().replaceAll("\n\t", "\n").replaceAll("\n\n", "\n").replaceAll("\n\n", "\n"));
GM_setClipboard(Temp[i].children[0].innerText.trim().replaceAll("\n\t", "\n").replaceAll("\n\n", "\n"));
CopyMDButton.innerText = "复制成功";
setTimeout(() => {
CopyMDButton.innerText = "复制";
Expand Down Expand Up @@ -3541,7 +3543,7 @@ int main()
CopyMDButton.type = "button";
document.querySelector("body > div > div.mt-3 > center > h2").appendChild(CopyMDButton);
CopyMDButton.addEventListener("click", () => {
GM_setClipboard(ParsedDocument.querySelector("body > div > div > div").innerText.trim().replaceAll("\n\t", "\n").replaceAll("\n\n", "\n").replaceAll("\n\n", "\n"));
GM_setClipboard(ParsedDocument.querySelector("body > div > div > div").innerText.trim().replaceAll("\n\t", "\n").replaceAll("\n\n", "\n"));
CopyMDButton.innerText = "复制成功";
setTimeout(() => {
CopyMDButton.innerText = "复制";
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": "1.2.14",
"version": "1.2.15",
"description": "an improvement script for xmoj.tech",
"main": "AddonScript.js",
"scripts": {
Expand Down

0 comments on commit bc034d4

Please sign in to comment.