This commit is contained in:
Xmader 2020-11-19 00:52:03 -05:00
parent 5426ad5059
commit f68a2ddada
No known key found for this signature in database
GPG Key ID: A20B97FB9EB730E4
3 changed files with 44 additions and 45 deletions

85
dist/main.js vendored
View File

@ -5,7 +5,7 @@
// @supportURL https://github.com/Xmader/musescore-downloader/issues // @supportURL https://github.com/Xmader/musescore-downloader/issues
// @updateURL https://msdl.librescore.org/install.user.js // @updateURL https://msdl.librescore.org/install.user.js
// @downloadURL https://msdl.librescore.org/install.user.js // @downloadURL https://msdl.librescore.org/install.user.js
// @version 0.15.9 // @version 0.15.10
// @description download sheet music from musescore.com for free, no login or Musescore Pro required | 免登录、免 Musescore Pro免费下载 musescore.com 上的曲谱 // @description download sheet music from musescore.com for free, no login or Musescore Pro required | 免登录、免 Musescore Pro免费下载 musescore.com 上的曲谱
// @author Xmader // @author Xmader
// @match https://musescore.com/*/* // @match https://musescore.com/*/*
@ -26537,59 +26537,58 @@ Please pipe the document into a Node stream.\
resolve(t); resolve(t);
}); });
}); });
const PACK_ID_REG = /\+(\{.*?"\})\[\w\]\+/;
const loadAllPacks = () => {
return webpackContext.then((ctx) => {
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.keys(packs).forEach((id) => {
ctx.e(id);
});
}
catch (err) {
console.error(err);
}
});
};
/* eslint-disable no-extend-native */ /* eslint-disable no-extend-native */
const AUTH_REG = /,((\d+\.\..+?)?function\(\)\{var \w=Array.prototype.slice.*?)\)(\[|\.then)/; const AUTH_REG = /,((\d+\.\..+?)?function\(\)\{var \w=Array.prototype.slice.*?)\)(\[|\.then)/;
const PACK_ID_REG = /\((\{.*?"\})\[\w\]\|\|\w\)/; var PACK_HINT;
const packIdPromise = webpackContext.then((ctx) => { (function (PACK_HINT) {
const ids = { PACK_HINT["img"] = "getImageRef";
img: '9', PACK_HINT["midi"] = "midi:";
midi: '', PACK_HINT["mp3"] = "setVolume:";
mp3: '', })(PACK_HINT || (PACK_HINT = {}));
};
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. * I know this is super hacky.
*/ */
const magicHookConstr = (type) => __awaiter(void 0, void 0, void 0, function* () { const magicHookConstr = (type) => __awaiter(void 0, void 0, void 0, function* () {
const packId = yield packIdPromise;
// request pack // request pack
// eslint-disable-next-line no-void, @typescript-eslint/no-unsafe-return yield loadAllPacks();
void webpackContext.then((ctx) => ctx.e(packId[type]));
return new Promise((resolve) => { return new Promise((resolve) => {
onPackLoad((pack) => { onPackLoad((pack) => {
if (pack[0].includes(packId[type]) || pack[0].includes(+packId[type])) { Object.values(pack[1]).forEach((mod) => {
Object.values(pack[1]).forEach((mod) => { const str = mod.toString();
const m = mod.toString().match(AUTH_REG); if (!str.includes(PACK_HINT[type])) {
if (m) { return;
const code = m[1]; }
try { const m = str.match(AUTH_REG);
// eslint-disable-next-line no-new-func, @typescript-eslint/no-implied-eval if (m) {
const magic = Function(`return (${code})`)(); const code = m[1];
resolve(magic); try {
} // eslint-disable-next-line no-new-func, @typescript-eslint/no-implied-eval
catch (err) { const magic = Function(`return (${code})`)();
console.error(err); resolve(magic);
}
} }
}); catch (err) {
} console.error(err);
}
}
});
}); });
}); });
}); });

2
package-lock.json generated
View File

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

View File

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