musescore-downloader

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit adad7867b760d893a2002633cae5a9911e9a4839
parent a3c54c5ebf8e33f3648e33400569baab0fc47f69
Author: Xmader <xmader@outlook.com>
Date:   Sun,  3 Nov 2019 15:21:59 -0500

v0.1.3 - debug

Diffstat:
Mdist/main.js | 14+++++++++-----
Mpackage.json | 2+-
Msrc/main.ts | 14+++++++++-----
3 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/dist/main.js b/dist/main.js @@ -3,7 +3,7 @@ // @namespace https://www.xmader.com/ // @homepageURL https://github.com/Xmader/musescore-downloader/ // @supportURL https://github.com/Xmader/musescore-downloader/issues -// @version 0.1.2 +// @version 0.1.3 // @description 免登录、免 Musescore Pro,下载 musescore.com 上的曲谱 // @author Xmader // @match https://musescore.com/user/*/scores/* @@ -32,8 +32,8 @@ const pdfURL = baseURL + "score_full.pdf"; const mxlURL = baseURL + "score.mxl"; const { midi: midiURL, mp3: mp3URL } = scorePlayer.urls; - const btnsDiv = document.querySelectorAll("aside section > div")[3]; - const downloadBtn = btnsDiv.querySelector("button"); + const btnsDiv = document.querySelector(".score-right .buttons-wrapper") || document.querySelectorAll("aside section > div")[3]; + const downloadBtn = btnsDiv.querySelector("button, .button"); downloadBtn.onclick = null; const downloadURLs = { "Musescore": msczURL, @@ -48,8 +48,12 @@ btn.onclick = () => { window.open(url); }; - btn.setAttribute("style", "width: 205px !important"); - const span = btn.querySelector("span"); + if (btn.nodeName.toLowerCase() == "button") { + btn.setAttribute("style", "width: 205px !important"); + } + const span = [...btn.childNodes].find((x) => { + return x.textContent.includes("Download"); + }); span.textContent = `Download ${name}`; return btn; }); diff --git a/package.json b/package.json @@ -1,6 +1,6 @@ { "name": "musescore-downloader", - "version": "0.1.2", + "version": "0.1.3", "description": "免登录、免 Musescore Pro,下载 musescore.com 上的曲谱", "main": "dist/main.js", "repository": { diff --git a/src/main.ts b/src/main.ts @@ -15,8 +15,8 @@ const pdfURL = baseURL + "score_full.pdf" const mxlURL = baseURL + "score.mxl" const { midi: midiURL, mp3: mp3URL } = scorePlayer.urls -const btnsDiv = document.querySelectorAll("aside section > div")[3] -const downloadBtn = btnsDiv.querySelector("button") +const btnsDiv = document.querySelector(".score-right .buttons-wrapper") || document.querySelectorAll("aside section > div")[3] +const downloadBtn = btnsDiv.querySelector("button, .button") as HTMLElement downloadBtn.onclick = null const downloadURLs = { @@ -30,14 +30,18 @@ const downloadURLs = { const newDownloadBtns = Object.keys(downloadURLs).map((name) => { const url = downloadURLs[name] - const btn = downloadBtn.cloneNode(true) as HTMLButtonElement + const btn = downloadBtn.cloneNode(true) as HTMLElement btn.onclick = () => { window.open(url) } - btn.setAttribute("style", "width: 205px !important") + if (btn.nodeName.toLowerCase() == "button") { + btn.setAttribute("style", "width: 205px !important") + } - const span = btn.querySelector("span") + const span = [...btn.childNodes].find((x) => { + return x.textContent.includes("Download") + }) span.textContent = `Download ${name}` return btn