v0.21.0
This commit is contained in:
parent
334b452fcc
commit
1831ffa7c8
|
@ -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.20.8
|
// @version 0.21.0
|
||||||
// @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/*/*
|
||||||
|
@ -13,13 +13,15 @@
|
||||||
// @license MIT
|
// @license MIT
|
||||||
// @copyright Copyright (c) 2019-2020 Xmader
|
// @copyright Copyright (c) 2019-2020 Xmader
|
||||||
// @grant unsafeWindow
|
// @grant unsafeWindow
|
||||||
|
// @grant GM.registerMenuCommand
|
||||||
|
// @grant GM.addElement
|
||||||
// @run-at document-start
|
// @run-at document-start
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
new Promise(resolve=>{const id=''+Math.random();(typeof unsafeWindow=='object'?unsafeWindow:window)[id]=resolve;setTimeout(`(function a(){window['${id}'](new Image())})()//# sourceURL=${location.href}`)}).then(d=>{d.style.display='none';d.src='data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';d.once=false;d.setAttribute('onload','if(this.once)return;this.once=true;this.remove();(' + function a () {
|
const w=typeof unsafeWindow=='object'?unsafeWindow:window;const gmId=''+Math.random();w[gmId]=typeof GM=='object'?GM:undefined;new Promise(resolve=>{const id=''+Math.random();w[id]=resolve;setTimeout(`(function a(){window['${id}'](new Image())})()//# sourceURL=${location.href}`)}).then(d=>{d.style.display='none';d.src='data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';d.once=false;d.setAttribute('onload',`if(this.once)return;this.once=true;this.remove();const GM=window['${gmId}'];(` + function a () {
|
||||||
|
|
||||||
function __awaiter(thisArg, _arguments, P, generator) {
|
function __awaiter(thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
@ -272,6 +274,12 @@
|
||||||
// Only Node.JS has a process variable that is of [[Class]] process
|
// Only Node.JS has a process variable that is of [[Class]] process
|
||||||
var detectNode = Object.prototype.toString.call(typeof process$1 !== 'undefined' ? process$1 : 0) === '[object process]';
|
var detectNode = Object.prototype.toString.call(typeof process$1 !== 'undefined' ? process$1 : 0) === '[object process]';
|
||||||
|
|
||||||
|
const _GM = GM;
|
||||||
|
const isGmAvailable = (requiredMethod = 'info') => {
|
||||||
|
return typeof GM !== 'undefined' &&
|
||||||
|
typeof GM[requiredMethod] !== 'undefined';
|
||||||
|
};
|
||||||
|
|
||||||
const escapeFilename = (s) => {
|
const escapeFilename = (s) => {
|
||||||
return s.replace(/[\s<>:{}"/\\|?*~.\0\cA-\cZ]+/g, '_');
|
return s.replace(/[\s<>:{}"/\\|?*~.\0\cA-\cZ]+/g, '_');
|
||||||
};
|
};
|
||||||
|
@ -316,6 +324,12 @@
|
||||||
const getSandboxWindowAsync = (targetEl = undefined) => __awaiter(void 0, void 0, void 0, function* () {
|
const getSandboxWindowAsync = (targetEl = undefined) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
if (typeof document === 'undefined')
|
if (typeof document === 'undefined')
|
||||||
return {};
|
return {};
|
||||||
|
if (isGmAvailable('addElement')) {
|
||||||
|
// create iframe using GM_addElement API
|
||||||
|
const iframe = yield _GM.addElement('iframe', {});
|
||||||
|
iframe.style.display = 'none';
|
||||||
|
return iframe.contentWindow;
|
||||||
|
}
|
||||||
if (!targetEl) {
|
if (!targetEl) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
// You need ads in your pages, right?
|
// You need ads in your pages, right?
|
||||||
|
@ -26526,7 +26540,7 @@ Please pipe the document into a Node stream.\
|
||||||
if (nodes[0].nodeName === 'IFRAME') {
|
if (nodes[0].nodeName === 'IFRAME') {
|
||||||
const iframe = nodes[0];
|
const iframe = nodes[0];
|
||||||
const w = iframe.contentWindow;
|
const w = iframe.contentWindow;
|
||||||
hookNative(w, 'fetch', (fn) => {
|
hookNative(w, 'fetch', () => {
|
||||||
return function (url, init) {
|
return function (url, init) {
|
||||||
var _a, _b;
|
var _a, _b;
|
||||||
const token = (_a = init === null || init === void 0 ? void 0 : init.headers) === null || _a === void 0 ? void 0 : _a.Authorization;
|
const token = (_a = init === null || init === void 0 ? void 0 : init.headers) === null || _a === void 0 ? void 0 : _a.Authorization;
|
||||||
|
@ -26538,7 +26552,7 @@ Please pipe the document into a Node stream.\
|
||||||
(_b = l[type]) === null || _b === void 0 ? void 0 : _b.call(l, token);
|
(_b = l[type]) === null || _b === void 0 ? void 0 : _b.call(l, token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fn(url, init);
|
return fetch(url, init);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -26954,6 +26968,13 @@ Please pipe the document into a Node stream.\
|
||||||
if (options.tooltip) {
|
if (options.tooltip) {
|
||||||
btnTpl.title = options.tooltip;
|
btnTpl.title = options.tooltip;
|
||||||
}
|
}
|
||||||
|
// add buttons to the userscript manager menu
|
||||||
|
if (isGmAvailable('registerMenuCommand')) {
|
||||||
|
// eslint-disable-next-line no-void
|
||||||
|
void _GM.registerMenuCommand(options.name, () => {
|
||||||
|
options.action(options.name, btnTpl, () => undefined);
|
||||||
|
});
|
||||||
|
}
|
||||||
return btnTpl;
|
return btnTpl;
|
||||||
}
|
}
|
||||||
_commit() {
|
_commit() {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "musescore-downloader",
|
"name": "musescore-downloader",
|
||||||
"version": "0.20.8",
|
"version": "0.21.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "musescore-downloader",
|
"name": "musescore-downloader",
|
||||||
"version": "0.20.8",
|
"version": "0.21.0",
|
||||||
"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",
|
||||||
"bin": "dist/cli.js",
|
"bin": "dist/cli.js",
|
||||||
|
|
Loading…
Reference in New Issue