v0.9.6
This commit is contained in:
parent
ef6cd56f4f
commit
517ba26312
2 changed files with 11 additions and 10 deletions
19
dist/main.js
vendored
19
dist/main.js
vendored
|
@ -3,7 +3,7 @@
|
||||||
// @namespace https://www.xmader.com/
|
// @namespace https://www.xmader.com/
|
||||||
// @homepageURL https://github.com/Xmader/musescore-downloader/
|
// @homepageURL https://github.com/Xmader/musescore-downloader/
|
||||||
// @supportURL https://github.com/Xmader/musescore-downloader/issues
|
// @supportURL https://github.com/Xmader/musescore-downloader/issues
|
||||||
// @version 0.9.5
|
// @version 0.9.6
|
||||||
// @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/*/*
|
||||||
|
@ -26437,6 +26437,7 @@ Please pipe the document into a Node stream.\
|
||||||
};
|
};
|
||||||
|
|
||||||
const FILE_URL_MODULE_ID = 'iNJA';
|
const FILE_URL_MODULE_ID = 'iNJA';
|
||||||
|
const MAGIC_REG = /^\d+(img|mp3|midi)\d(.+)$/;
|
||||||
const getApiUrl = (id, type, index) => {
|
const getApiUrl = (id, type, index) => {
|
||||||
// proxy
|
// proxy
|
||||||
return `https://musescore.now.sh/api/jmuse?id=${id}&type=${type}&index=${index}`;
|
return `https://musescore.now.sh/api/jmuse?id=${id}&type=${type}&index=${index}`;
|
||||||
|
@ -26445,13 +26446,13 @@ Please pipe the document into a Node stream.\
|
||||||
* I know this is super hacky.
|
* I know this is super hacky.
|
||||||
*/
|
*/
|
||||||
let magic = new Promise((resolve) => {
|
let magic = new Promise((resolve) => {
|
||||||
const reg = /^\d+(img|mp3|midi)\d(.+)$/;
|
// reserve for future hook update
|
||||||
const method = 'encodeURIComponent';
|
const method = 'encodeURIComponent';
|
||||||
const _fn = window[method];
|
const _fn = window[method];
|
||||||
// This script can run before anything on the page,
|
// This script can run before anything on the page,
|
||||||
// so setting `encodeURIComponent` to be non-configurable and non-writable is no use.
|
// so setting `encodeURIComponent` to be non-configurable and non-writable is no use.
|
||||||
window[method] = (s) => {
|
window[method] = (s) => {
|
||||||
const m = s.toString().match(reg);
|
const m = s.toString().match(MAGIC_REG);
|
||||||
if (m) {
|
if (m) {
|
||||||
// the auth string will be encoded using `encodeURIComponent` before `md5`,
|
// the auth string will be encoded using `encodeURIComponent` before `md5`,
|
||||||
// so hook here
|
// so hook here
|
||||||
|
@ -26687,12 +26688,12 @@ Please pipe the document into a Node stream.\
|
||||||
window.open(yield normalizeUrlInput(url));
|
window.open(yield normalizeUrlInput(url));
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
BtnAction.download = (url, filename) => {
|
BtnAction.download = (url) => {
|
||||||
return BtnAction.process(() => __awaiter(this, void 0, void 0, function* () {
|
return BtnAction.process(() => __awaiter(this, void 0, void 0, function* () {
|
||||||
const _url = yield normalizeUrlInput(url);
|
const _url = yield normalizeUrlInput(url);
|
||||||
const r = yield fetch(_url);
|
const a = document.createElement('a');
|
||||||
const blob = yield r.blob();
|
a.href = _url;
|
||||||
saveAs(blob, filename);
|
a.dispatchEvent(new MouseEvent('click'));
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
BtnAction.mscoreWindow = (fn) => {
|
BtnAction.mscoreWindow = (fn) => {
|
||||||
|
@ -26771,11 +26772,11 @@ Please pipe the document into a Node stream.\
|
||||||
});
|
});
|
||||||
btnList.add({
|
btnList.add({
|
||||||
name: 'Download MIDI',
|
name: 'Download MIDI',
|
||||||
action: BtnAction.deprecate(BtnAction.download(() => getFileUrl('midi'), `${filename}.mid`)),
|
action: BtnAction.deprecate(BtnAction.download(() => getFileUrl('midi'))),
|
||||||
});
|
});
|
||||||
btnList.add({
|
btnList.add({
|
||||||
name: 'Download MP3',
|
name: 'Download MP3',
|
||||||
action: BtnAction.download(() => getFileUrl('mp3'), `${filename}.mp3`),
|
action: BtnAction.download(() => getFileUrl('mp3')),
|
||||||
});
|
});
|
||||||
btnList.add({
|
btnList.add({
|
||||||
name: 'Individual Parts',
|
name: 'Individual Parts',
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "musescore-downloader",
|
"name": "musescore-downloader",
|
||||||
"version": "0.9.5",
|
"version": "0.9.6",
|
||||||
"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": {
|
||||||
|
|
Loading…
Reference in a new issue