5
5
// @supportURL https://github.com/Xmader/musescore-downloader/issues
6
6
// @updateURL https://msdl.librescore.org/install.user.js
7
7
// @downloadURL https://msdl.librescore.org/install.user.js
8
- // @version 0.23.15
8
+ // @version 0.24.0
9
9
// @description download sheet music from musescore.com for free, no login or Musescore Pro required | 免登录、免 Musescore Pro,免费下载 musescore.com 上的曲谱
10
10
// @author Xmader
11
11
// @match https://musescore.com/*/*
@@ -27056,7 +27056,7 @@ Please pipe the document into a Node stream.\
27056
27056
return _getLink(res);
27057
27057
});
27058
27058
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}";
27060
27060
27061
27061
var ICON;
27062
27062
(function (ICON) {
@@ -27076,15 +27076,17 @@ Please pipe the document into a Node stream.\
27076
27076
throw new Error('btn parent not found');
27077
27077
return btnParent;
27078
27078
};
27079
- const buildDownloadBtn = (icon) => {
27079
+ const buildDownloadBtn = (icon, lightTheme = false ) => {
27080
27080
const btn = document.createElement('button');
27081
27081
btn.type = 'button';
27082
+ if (lightTheme)
27083
+ btn.className = 'light';
27082
27084
// build icon svg element
27083
27085
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
27084
27086
svg.setAttribute('viewBox', '0 0 24 24');
27085
27087
const svgPath = document.createElementNS('http://www.w3.org/2000/svg', 'path');
27086
27088
svgPath.setAttribute('d', icon);
27087
- svgPath.setAttribute('fill', '#fff');
27089
+ svgPath.setAttribute('fill', lightTheme ? '#2e68c0' : '#fff');
27088
27090
svg.append(svgPath);
27089
27091
const textNode = document.createElement('span');
27090
27092
btn.append(svg, textNode);
@@ -27103,6 +27105,22 @@ Please pipe the document into a Node stream.\
27103
27105
return getScrollParent(node.parentNode);
27104
27106
}
27105
27107
}
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
+ }
27106
27124
var BtnListMode;
27107
27125
(function (BtnListMode) {
27108
27126
BtnListMode[BtnListMode["InPage"] = 0] = "InPage";
@@ -27115,7 +27133,7 @@ Please pipe the document into a Node stream.\
27115
27133
}
27116
27134
add(options) {
27117
27135
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 );
27119
27137
const setText = (btn) => {
27120
27138
const textNode = btn.querySelector('span');
27121
27139
return (str) => {
@@ -27167,21 +27185,17 @@ Please pipe the document into a Node stream.\
27167
27185
const newParent = document.createElement('div');
27168
27186
newParent.append(...this.list.map(e => cloneBtn(e)));
27169
27187
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) => {
27174
27191
const pos = () => this._positionBtns(anchorDiv, newParent);
27175
27192
pos();
27176
27193
// reposition btns when window resizes
27177
27194
window.addEventListener('resize', pos, { passive: true });
27178
27195
// reposition btns when scrolling
27179
27196
const scroll = getScrollParent(anchorDiv);
27180
27197
scroll.addEventListener('scroll', pos, { passive: true });
27181
- }
27182
- catch (err) {
27183
- console$1.error(err);
27184
- }
27198
+ });
27185
27199
return btnParent;
27186
27200
}
27187
27201
/**
@@ -27429,7 +27443,7 @@ Please pipe the document into a Node stream.\
27429
27443
action: BtnAction.process(() => downloadPDF(scoreinfo, new SheetInfoInPage(document)), fallback, 3 * 60 * 1000 /* 3min */),
27430
27444
});
27431
27445
btnList.add({
27432
- name: i18n('DOWNLOAD')('MusicXML '),
27446
+ name: i18n('DOWNLOAD')('MXL '),
27433
27447
action: BtnAction.mscoreWindow(scoreinfo, (w, score) => __awaiter(void 0, void 0, void 0, function* () {
27434
27448
const mxl = yield score.saveMxl();
27435
27449
const data = new Blob([mxl]);
@@ -27509,7 +27523,9 @@ Please pipe the document into a Node stream.\
27509
27523
action: BtnAction.openUrl(() => getLibreScoreLink(scoreinfo)),
27510
27524
tooltip: 'BETA',
27511
27525
icon: ICON.LIBRESCORE,
27526
+ lightTheme: true,
27512
27527
});
27528
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
27513
27529
btnList.commit(BtnListMode.InPage);
27514
27530
};
27515
27531
// eslint-disable-next-line @typescript-eslint/no-floating-promises
0 commit comments