From 7f5ac931cb8d01adaa3510b6f72ed4687187b6c8 Mon Sep 17 00:00:00 2001 From: Xmader Date: Fri, 23 Oct 2020 11:05:50 -0400 Subject: [PATCH] v0.9.4 - #38 --- dist/main.js | 47 +++++++++++++++++++++++++++++++++++------------ package.json | 2 +- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/dist/main.js b/dist/main.js index f56bd62..00efe50 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.9.3 +// @version 0.9.4 // @description download sheet music from musescore.com for free, no login or Musescore Pro required | 免登录、免 Musescore Pro,免费下载 musescore.com 上的曲谱 // @author Xmader // @match https://musescore.com/*/* @@ -221,11 +221,13 @@ const waitForDocumentLoaded = () => { if (document.readyState !== 'complete') { return new Promise(resolve => { - document.addEventListener('readystatechange', () => { + const cb = () => { if (document.readyState === 'complete') { resolve(); + document.removeEventListener('readystatechange', cb); } - }, { once: true }); + }; + document.addEventListener('readystatechange', cb); }); } else { @@ -26317,9 +26319,15 @@ Please pipe the document into a Node stream.\ /* eslint-disable @typescript-eslint/no-unsafe-return */ // run at document-start const ugappJsStore = (() => { - const el = document.querySelector('.js-store'); - const json = el.dataset.content; - return JSON.parse(json); + try { + const el = document.querySelector('.js-store'); + const json = el.dataset.content; + return JSON.parse(json); + } + catch (err) { + console.error(err); + return null; + } })(); const scoreinfo = { get playerdata() { @@ -26327,14 +26335,22 @@ Please pipe the document into a Node stream.\ return ugappJsStore.store.page.data.score; }, get id() { - return this.playerdata.id; + try { + return this.playerdata.id; + } + catch (_a) { + const el = document.querySelector("meta[property='al:ios:url']"); + const m = el.content.match(/(\d+)$/); + return +m[1]; + } }, get title() { try { return this.playerdata.title; } - catch (_) { - return ''; + catch (_a) { + const el = document.querySelector("meta[property='og:title']"); + return el.content; } }, get fileName() { @@ -26344,12 +26360,19 @@ Please pipe the document into a Node stream.\ try { return this.playerdata.pages_count; } - catch (_) { - return document.querySelectorAll('img[src*=score_]').length; + catch (_a) { + return document.querySelectorAll('.gXB83').length; } }, get baseUrl() { - const thumbnailUrl = this.playerdata.thumbnails.original; + let thumbnailUrl; + try { + thumbnailUrl = this.playerdata.thumbnails.original; + } + catch (_a) { + const el = document.querySelector("meta[property='og:image']"); + thumbnailUrl = el.content; + } const { origin, pathname } = new URL(thumbnailUrl); // remove the last part return origin + pathname.split('/').slice(0, -1).join('/') + '/'; diff --git a/package.json b/package.json index 2156e1f..74137f9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "musescore-downloader", - "version": "0.9.3", + "version": "0.9.4", "description": "download sheet music from musescore.com for free, no login or Musescore Pro required | 免登录、免 Musescore Pro,免费下载 musescore.com 上的曲谱", "main": "dist/main.js", "repository": {