From 1f44fcf449e1322afb18556e8ee34b518d519847 Mon Sep 17 00:00:00 2001 From: Xmader Date: Tue, 10 Nov 2020 13:37:16 -0500 Subject: [PATCH] v0.12.5 --- dist/main.js | 48 ++++++++++++++++++++--------------------------- package-lock.json | 2 +- package.json | 2 +- 3 files changed, 22 insertions(+), 30 deletions(-) diff --git a/dist/main.js b/dist/main.js index 920e9bc..90d0c9e 100644 --- a/dist/main.js +++ b/dist/main.js @@ -26786,7 +26786,7 @@ Please pipe the document into a Node stream.\ * Select the original Download Button */ const getDownloadBtn = () => { - const btnsDiv = document.querySelector('.score-right .buttons-wrapper') || document.querySelectorAll('aside > section > section > div')[3]; + const btnsDiv = document.querySelector('.score-right .buttons-wrapper') || document.querySelectorAll('aside>section>section')[0].children[3]; const btn = btnsDiv.querySelector('button, .button'); btn.onclick = null; // fix the icon of the download btn @@ -26803,32 +26803,14 @@ Please pipe the document into a Node stream.\ } return btn; }; - const SCORE_BTN_MODULE_ID = 'WYqd'; - webpackGlobalOverride(SCORE_BTN_MODULE_ID, (_, r, t) => { - const fn = r.a; - let firstTime = true; - // the root container of btns refreshes every 1s - t.d(r, 'a', () => { - return function () { - if (!firstTime) { - // force state update - this.__H.__[0].__[0] = 0; - } - else { - firstTime = false; - } - return fn(); - }; - }); - }); class BtnList { - constructor(templateBtn) { - this.templateBtn = templateBtn; + constructor(getTemplateBtn) { + this.getTemplateBtn = getTemplateBtn; this.list = []; this.antiDetectionText = 'Download'; } add(options) { - const btn = this.templateBtn.cloneNode(true); + const btn = this.getTemplateBtn().cloneNode(true); const textNode = [...btn.childNodes].find((x) => { const txt = x.textContent; return txt.includes('Download') || txt.includes('Print'); @@ -26864,11 +26846,8 @@ Please pipe the document into a Node stream.\ } return btn; } - /** - * replace the template button with the list of new buttons - */ - commit() { - const parent = this.templateBtn.parentElement; + _commit() { + const parent = this.getTemplateBtn().parentElement; const shadow = parent.attachShadow({ mode: 'closed' }); // style the shadow DOM from outside css document.head.querySelectorAll('style').forEach(s => { @@ -26878,6 +26857,19 @@ Please pipe the document into a Node stream.\ const newParent = parent.cloneNode(false); newParent.append(...this.list); shadow.append(newParent); + return parent; + } + /** + * replace the template button with the list of new buttons + */ + commit() { + let el = this._commit(); + const observer = new MutationObserver(() => { + if (!document.contains(el)) { + el = this._commit(); + } + }); + observer.observe(document, { childList: true, subtree: true }); } } // eslint-disable-next-line @typescript-eslint/no-namespace @@ -26957,7 +26949,7 @@ Please pipe the document into a Node stream.\ // init recaptcha // eslint-disable-next-line @typescript-eslint/no-floating-promises init(); - const btnList = new BtnList(getDownloadBtn()); + const btnList = new BtnList(getDownloadBtn); const filename = scoreinfo.fileName; btnList.add({ name: i18n('DOWNLOAD')('MSCZ'), diff --git a/package-lock.json b/package-lock.json index 2314369..60c4bad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "musescore-downloader", - "version": "0.12.4", + "version": "0.12.5", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 0751663..0a601b9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "musescore-downloader", - "version": "0.12.4", + "version": "0.12.5", "description": "download sheet music from musescore.com for free, no login or Musescore Pro required | 免登录、免 Musescore Pro,免费下载 musescore.com 上的曲谱", "main": "dist/main.js", "repository": {