Skip to content

Commit 3ac3a51

Browse files
committed
v0.24.0
1 parent 9c05dd5 commit 3ac3a51

File tree

3 files changed

+32
-16
lines changed

3 files changed

+32
-16
lines changed

dist/main.js

+30-14
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// @supportURL https://github.com/Xmader/musescore-downloader/issues
66
// @updateURL https://msdl.librescore.org/install.user.js
77
// @downloadURL https://msdl.librescore.org/install.user.js
8-
// @version 0.23.15
8+
// @version 0.24.0
99
// @description download sheet music from musescore.com for free, no login or Musescore Pro required | 免登录、免 Musescore Pro,免费下载 musescore.com 上的曲谱
1010
// @author Xmader
1111
// @match https://musescore.com/*/*
@@ -27056,7 +27056,7 @@ Please pipe the document into a Node stream.\
2705627056
return _getLink(res);
2705727057
});
2705827058

27059-
var btnListCss = "div {\n width: 422px;\n right: 0;\n margin: 0 18px 18px 0;\n\n text-align: center;\n align-items: center;\n font-family: 'Open Sans', 'Roboto', 'Helvetica neue', Helvetica, sans-serif;\n position: absolute;\n z-index: 9999;\n background: #f6f6f6;\n min-width: 230px;\n\n /* pass the scroll event through the btns background */\n pointer-events: none;\n}\n\n@media screen and (max-width: 950px) {\n div {\n width: auto !important;\n }\n}\n\nbutton {\n width: 205px !important;\n min-width: 205px;\n height: 38px;\n\n color: #fff;\n background: #1f74bd;\n\n cursor: pointer;\n pointer-events: auto;\n\n margin-bottom: 4px;\n margin-right: 4px;\n padding: 4px 12px;\n\n justify-content: start;\n align-self: center;\n\n font-size: 16px;\n border-radius: 2px;\n border: 0;\n\n display: inline-flex;\n position: relative;\n\n font-family: inherit;\n}\n\n/* fix `View in LibreScore` button text overflow */\nbutton:last-of-type {\n width: unset !important;\n}\n\nsvg {\n display: inline-block;\n margin-right: 5px;\n width: 20px;\n height: 20px;\n margin-top: auto;\n margin-bottom: auto;\n}\n\nspan {\n margin-top: auto;\n margin-bottom: auto;\n}";
27059+
var btnListCss = "div {\n width: 422px;\n right: 0;\n margin: 0 18px 18px 0;\n\n text-align: center;\n align-items: center;\n font-family: 'Inter', 'Helvetica neue', Helvetica, sans-serif;\n position: absolute;\n z-index: 9999;\n background: #f6f6f6;\n min-width: 230px;\n\n /* pass the scroll event through the btns background */\n pointer-events: none;\n}\n\n@media screen and (max-width: 950px) {\n div {\n width: auto !important;\n }\n}\n\nbutton {\n width: 178px !important;\n min-width: 178px;\n height: 40px;\n\n color: #fff;\n background: #2e68c0;\n\n cursor: pointer;\n pointer-events: auto;\n\n margin-bottom: 8px;\n margin-right: 8px;\n padding: 4px 12px;\n\n justify-content: start;\n align-self: center;\n\n font-size: 16px;\n border-radius: 6px;\n border: 0;\n\n display: inline-flex;\n position: relative;\n\n font-family: inherit;\n}\n\n/* fix `View in LibreScore` button text overflow */\nbutton:last-of-type {\n width: unset !important;\n}\n\nbutton:hover {\n background: #1a4f9f;\n}\n\n/* light theme btn */\nbutton.light {\n color: #2e68c0;\n background: #e1effe;\n}\n\nbutton.light:hover {\n background: #c3ddfd;\n}\n\nsvg {\n display: inline-block;\n margin-right: 5px;\n width: 20px;\n height: 20px;\n margin-top: auto;\n margin-bottom: auto;\n}\n\nspan {\n margin-top: auto;\n margin-bottom: auto;\n}";
2706027060

2706127061
var ICON;
2706227062
(function (ICON) {
@@ -27076,15 +27076,17 @@ Please pipe the document into a Node stream.\
2707627076
throw new Error('btn parent not found');
2707727077
return btnParent;
2707827078
};
27079-
const buildDownloadBtn = (icon) => {
27079+
const buildDownloadBtn = (icon, lightTheme = false) => {
2708027080
const btn = document.createElement('button');
2708127081
btn.type = 'button';
27082+
if (lightTheme)
27083+
btn.className = 'light';
2708227084
// build icon svg element
2708327085
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
2708427086
svg.setAttribute('viewBox', '0 0 24 24');
2708527087
const svgPath = document.createElementNS('http://www.w3.org/2000/svg', 'path');
2708627088
svgPath.setAttribute('d', icon);
27087-
svgPath.setAttribute('fill', '#fff');
27089+
svgPath.setAttribute('fill', lightTheme ? '#2e68c0' : '#fff');
2708827090
svg.append(svgPath);
2708927091
const textNode = document.createElement('span');
2709027092
btn.append(svg, textNode);
@@ -27103,6 +27105,22 @@ Please pipe the document into a Node stream.\
2710327105
return getScrollParent(node.parentNode);
2710427106
}
2710527107
}
27108+
function onPageRendered(getEl) {
27109+
return new Promise((resolve) => {
27110+
var _a;
27111+
const observer = new MutationObserver(() => {
27112+
try {
27113+
const el = getEl();
27114+
if (el) {
27115+
observer.disconnect();
27116+
resolve(el);
27117+
}
27118+
}
27119+
catch (_a) { }
27120+
});
27121+
observer.observe((_a = document.querySelector('div > section')) !== null && _a !== void 0 ? _a : document.body, { childList: true, subtree: true });
27122+
});
27123+
}
2710627124
var BtnListMode;
2710727125
(function (BtnListMode) {
2710827126
BtnListMode[BtnListMode["InPage"] = 0] = "InPage";
@@ -27115,7 +27133,7 @@ Please pipe the document into a Node stream.\
2711527133
}
2711627134
add(options) {
2711727135
var _a;
27118-
const btnTpl = buildDownloadBtn((_a = options.icon) !== null && _a !== void 0 ? _a : ICON.DOWNLOAD);
27136+
const btnTpl = buildDownloadBtn((_a = options.icon) !== null && _a !== void 0 ? _a : ICON.DOWNLOAD, options.lightTheme);
2711927137
const setText = (btn) => {
2712027138
const textNode = btn.querySelector('span');
2712127139
return (str) => {
@@ -27167,21 +27185,17 @@ Please pipe the document into a Node stream.\
2716727185
const newParent = document.createElement('div');
2716827186
newParent.append(...this.list.map(e => cloneBtn(e)));
2716927187
shadow.append(newParent);
27170-
// default position
27171-
newParent.style.top = '0px';
27172-
try {
27173-
const anchorDiv = this.getBtnParent();
27188+
// default position
27189+
newParent.style.top = `${window.innerHeight - newParent.getBoundingClientRect().height}px`;
27190+
void onPageRendered(this.getBtnParent).then((anchorDiv) => {
2717427191
const pos = () => this._positionBtns(anchorDiv, newParent);
2717527192
pos();
2717627193
// reposition btns when window resizes
2717727194
window.addEventListener('resize', pos, { passive: true });
2717827195
// reposition btns when scrolling
2717927196
const scroll = getScrollParent(anchorDiv);
2718027197
scroll.addEventListener('scroll', pos, { passive: true });
27181-
}
27182-
catch (err) {
27183-
console$1.error(err);
27184-
}
27198+
});
2718527199
return btnParent;
2718627200
}
2718727201
/**
@@ -27429,7 +27443,7 @@ Please pipe the document into a Node stream.\
2742927443
action: BtnAction.process(() => downloadPDF(scoreinfo, new SheetInfoInPage(document)), fallback, 3 * 60 * 1000 /* 3min */),
2743027444
});
2743127445
btnList.add({
27432-
name: i18n('DOWNLOAD')('MusicXML'),
27446+
name: i18n('DOWNLOAD')('MXL'),
2743327447
action: BtnAction.mscoreWindow(scoreinfo, (w, score) => __awaiter(void 0, void 0, void 0, function* () {
2743427448
const mxl = yield score.saveMxl();
2743527449
const data = new Blob([mxl]);
@@ -27509,7 +27523,9 @@ Please pipe the document into a Node stream.\
2750927523
action: BtnAction.openUrl(() => getLibreScoreLink(scoreinfo)),
2751027524
tooltip: 'BETA',
2751127525
icon: ICON.LIBRESCORE,
27526+
lightTheme: true,
2751227527
});
27528+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
2751327529
btnList.commit(BtnListMode.InPage);
2751427530
};
2751527531
// eslint-disable-next-line @typescript-eslint/no-floating-promises

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "musescore-downloader",
3-
"version": "0.23.15",
3+
"version": "0.24.0",
44
"description": "download sheet music from musescore.com for free, no login or Musescore Pro required | 免登录、免 Musescore Pro,免费下载 musescore.com 上的曲谱",
55
"main": "dist/main.js",
66
"bin": "dist/cli.js",

0 commit comments

Comments
 (0)