This commit is contained in:
Xmader 2020-11-18 18:36:01 -05:00
parent 06b7bda575
commit eaff7b123c
No known key found for this signature in database
GPG Key ID: A20B97FB9EB730E4
3 changed files with 33 additions and 14 deletions

43
dist/main.js vendored
View File

@ -5,7 +5,7 @@
// @supportURL https://github.com/Xmader/musescore-downloader/issues
// @updateURL https://msdl.librescore.org/install.user.js
// @downloadURL https://msdl.librescore.org/install.user.js
// @version 0.15.8
// @version 0.15.9
// @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/*/*
@ -26539,23 +26539,42 @@ Please pipe the document into a Node stream.\
});
/* eslint-disable no-extend-native */
const AUTH_REG = /,(function\(\)\{var \w=Array.prototype.slice.*?)\)\[/;
var PACK_ID;
(function (PACK_ID) {
PACK_ID["img"] = "F/w+";
PACK_ID["midi"] = "yihj";
PACK_ID["mp3"] = "2oYV";
})(PACK_ID || (PACK_ID = {}));
const AUTH_REG = /,((\d+\.\..+?)?function\(\)\{var \w=Array.prototype.slice.*?)\)(\[|\.then)/;
const PACK_ID_REG = /\((\{.*?"\})\[\w\]\|\|\w\)/;
const packIdPromise = webpackContext.then((ctx) => {
const ids = {
img: '9',
midi: '',
mp3: '',
};
try {
const fn = ctx.e.toString();
const packsData = fn.match(PACK_ID_REG)[1];
// eslint-disable-next-line no-new-func, @typescript-eslint/no-implied-eval
const packs = Function(`return (${packsData})`)();
Object.entries(packs).forEach(([id, name]) => {
if (name.includes('audio') && !ids['mp3'])
ids['mp3'] = id;
if (name.includes('piano_roll') && !ids['midi'])
ids['midi'] = id;
});
}
catch (err) {
console.error(err);
}
return ids;
});
/**
* I know this is super hacky.
*/
const magicHookConstr = (type) => {
const magicHookConstr = (type) => __awaiter(void 0, void 0, void 0, function* () {
const packId = yield packIdPromise;
// request pack
// eslint-disable-next-line no-void, @typescript-eslint/no-unsafe-return
void webpackContext.then((ctx) => ctx.e(PACK_ID[type]));
void webpackContext.then((ctx) => ctx.e(packId[type]));
return new Promise((resolve) => {
onPackLoad((pack) => {
if (pack[0].includes(PACK_ID[type])) {
if (pack[0].includes(packId[type]) || pack[0].includes(+packId[type])) {
Object.values(pack[1]).forEach((mod) => {
const m = mod.toString().match(AUTH_REG);
if (m) {
@ -26573,7 +26592,7 @@ Please pipe the document into a Node stream.\
}
});
});
};
});
const magics = {
img: magicHookConstr('img'),
midi: magicHookConstr('midi'),

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "musescore-downloader",
"version": "0.15.8",
"version": "0.15.9",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "musescore-downloader",
"version": "0.15.8",
"version": "0.15.9",
"description": "download sheet music from musescore.com for free, no login or Musescore Pro required | 免登录、免 Musescore Pro免费下载 musescore.com 上的曲谱",
"main": "dist/main.js",
"repository": {