Skip to content

Commit

Permalink
v0.12.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Xmader committed Nov 10, 2020
1 parent 942acd0 commit 1f44fcf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 30 deletions.
48 changes: 20 additions & 28 deletions dist/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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');
Expand Down Expand Up @@ -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 => {
Expand All @@ -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
Expand Down Expand Up @@ -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'),
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit 1f44fcf

Please sign in to comment.