initial commit
This commit is contained in:
commit
2c8b3c1360
11 changed files with 372 additions and 0 deletions
53
dist/main.js
vendored
Normal file
53
dist/main.js
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
// ==UserScript==
|
||||
// @name musescore-downloader
|
||||
// @namespace https://www.xmader.com/
|
||||
// @version 0.1.0
|
||||
// @description 免登录、免 Musescore Pro,下载 musescore.com 上的曲谱
|
||||
// @author Xmader
|
||||
// @match https://musescore.com/user/*/scores/*
|
||||
// @license MIT
|
||||
// @copyright Copyright (c) 2019 Xmader
|
||||
// @grant none
|
||||
// ==/UserScript==
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
const getIndexPath = (id) => {
|
||||
const idStr = String(id);
|
||||
// 获取最后三位,倒序排列
|
||||
// "5449062" -> ["2", "6", "0"]
|
||||
const indexN = idStr.split("").reverse().slice(0, 3);
|
||||
return indexN.join("/");
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
const scorePlayer = window.UGAPP.store.jmuse_settings.score_player;
|
||||
const { id, vid } = scorePlayer.json;
|
||||
const baseURL = scorePlayer.urls.image_path;
|
||||
const scoreHexId = baseURL.split("/").filter(Boolean).reverse()[1];
|
||||
const msczURL = `https://musescore.com/static/musescore/scoredata/score/${getIndexPath}/${id}/score_${vid}_${scoreHexId}.mscz`;
|
||||
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");
|
||||
downloadBtn.onclick = null;
|
||||
const downloadURLs = {
|
||||
"Musescore": msczURL,
|
||||
"PDF": pdfURL,
|
||||
"MusicXML": mxlURL,
|
||||
"MIDI": midiURL,
|
||||
"MP3": mp3URL,
|
||||
};
|
||||
const newDownloadBtns = Object.keys(downloadURLs).map((name) => {
|
||||
const url = downloadURLs[name];
|
||||
const btn = downloadBtn.cloneNode(true);
|
||||
btn.onclick = () => {
|
||||
window.open(url);
|
||||
};
|
||||
return btn;
|
||||
});
|
||||
downloadBtn.replaceWith(...newDownloadBtns);
|
||||
|
||||
}());
|
Loading…
Add table
Add a link
Reference in a new issue