From 5c7203b15597372e741219b89ee005d5fcc367f4 Mon Sep 17 00:00:00 2001 From: Xmader Date: Sun, 1 Dec 2019 00:16:07 -0500 Subject: [PATCH] v0.2.0 - fix `Download Musescore` button --- dist/main.js | 18 +++++------------- package.json | 2 +- src/main.ts | 11 +++++++---- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/dist/main.js b/dist/main.js index 4c01980..cfce429 100644 --- 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.7 +// @version 0.2.0 // @description 免登录、免 Musescore Pro,下载 musescore.com 上的曲谱 // @author Xmader // @match https://musescore.com/*/* @@ -15,15 +15,6 @@ (function () { 'use strict'; - const getIndexPath = (id) => { - const idStr = String(id); - // 获取最后三位,倒序排列 - // x, y, z are the reversed last digits of the score id. Example: id 123456789, x = 9, y = 8, z = 7 - // https://developers.musescore.com/#/file-urls - // "5449062" -> ["2", "6", "0"] - const indexN = idStr.split("").reverse().slice(0, 3); - return indexN.join("/"); - }; const waitForDocumentLoaded = () => { if (document.readyState !== "complete") { return new Promise(resolve => { @@ -46,10 +37,11 @@ } // @ts-ignore const scorePlayer = window.UGAPP.store.jmuse_settings.score_player; - const { id, vid } = scorePlayer.json; + const { id } = scorePlayer.json; const baseURL = scorePlayer.urls.image_path; - const scoreHexId = baseURL.split("/").filter(Boolean).reverse()[0]; - const msczURL = `https://musescore.com/static/musescore/scoredata/score/${getIndexPath(id)}/${id}/score_${vid}_${scoreHexId}.mscz`; + // const msczURL = `https://musescore.com/static/musescore/scoredata/score/${getIndexPath(id)}/${id}/score_${vid}_${scoreHexId}.mscz` + // https://github.com/Xmader/cloudflare-worker-musescore-mscz + const msczURL = `https://musescore-mscz.99.workers.dev/${id}`; const pdfURL = baseURL + "score_full.pdf"; const mxlURL = baseURL + "score.mxl"; const { midi: midiURL, mp3: mp3URL } = scorePlayer.urls; diff --git a/package.json b/package.json index 6d2277f..3efc139 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "musescore-downloader", - "version": "0.1.7", + "version": "0.2.0", "description": "download sheet music from musescore.com for free, no login or Musescore Pro required | 免登录、免 Musescore Pro,免费下载 musescore.com 上的曲谱", "main": "dist/main.js", "repository": { diff --git a/src/main.ts b/src/main.ts index 3d45f5b..a61b540 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,7 +1,7 @@ import "./meta" import { ScorePlayerData } from "./types" -import { getIndexPath, waitForDocumentLoaded } from "./utils" +import { waitForDocumentLoaded } from "./utils" const main = () => { @@ -11,11 +11,14 @@ const main = () => { // @ts-ignore const scorePlayer: ScorePlayerData = window.UGAPP.store.jmuse_settings.score_player - const { id, vid } = scorePlayer.json + const { id } = scorePlayer.json const baseURL = scorePlayer.urls.image_path - const scoreHexId = baseURL.split("/").filter(Boolean).reverse()[0] - const msczURL = `https://musescore.com/static/musescore/scoredata/score/${getIndexPath(id)}/${id}/score_${vid}_${scoreHexId}.mscz` + // const msczURL = `https://musescore.com/static/musescore/scoredata/score/${getIndexPath(id)}/${id}/score_${vid}_${scoreHexId}.mscz` + + // https://github.com/Xmader/cloudflare-worker-musescore-mscz + const msczURL = `https://musescore-mscz.99.workers.dev/${id}` + const pdfURL = baseURL + "score_full.pdf" const mxlURL = baseURL + "score.mxl" const { midi: midiURL, mp3: mp3URL } = scorePlayer.urls