Skip to content

Commit

Permalink
v0.21.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Xmader committed Dec 6, 2020
1 parent 334b452 commit 1831ffa
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
29 changes: 25 additions & 4 deletions dist/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@
// @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.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 上的曲谱
// @author Xmader
// @match https://musescore.com/*/*
// @match https://s.musescore.com/*/*
// @license MIT
// @copyright Copyright (c) 2019-2020 Xmader
// @grant unsafeWindow
// @grant GM.registerMenuCommand
// @grant GM.addElement
// @run-at document-start
// ==/UserScript==

(function () {
'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 adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
Expand Down Expand Up @@ -272,6 +274,12 @@
// 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]';

const _GM = GM;
const isGmAvailable = (requiredMethod = 'info') => {
return typeof GM !== 'undefined' &&
typeof GM[requiredMethod] !== 'undefined';
};

const escapeFilename = (s) => {
return s.replace(/[\s<>:{}"/\\|?*~.\0\cA-\cZ]+/g, '_');
};
Expand Down Expand Up @@ -316,6 +324,12 @@
const getSandboxWindowAsync = (targetEl = undefined) => __awaiter(void 0, void 0, void 0, function* () {
if (typeof document === 'undefined')
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) {
return new Promise((resolve) => {
// You need ads in your pages, right?
Expand Down Expand Up @@ -26526,7 +26540,7 @@ Please pipe the document into a Node stream.\
if (nodes[0].nodeName === 'IFRAME') {
const iframe = nodes[0];
const w = iframe.contentWindow;
hookNative(w, 'fetch', (fn) => {
hookNative(w, 'fetch', () => {
return function (url, init) {
var _a, _b;
const token = (_a = init === null || init === void 0 ? void 0 : init.headers) === null || _a === void 0 ? void 0 : _a.Authorization;
Expand All @@ -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);
}
}
return fn(url, init);
return fetch(url, init);
};
});
}
Expand Down Expand Up @@ -26954,6 +26968,13 @@ Please pipe the document into a Node stream.\
if (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;
}
_commit() {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"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 上的曲谱",
"main": "dist/main.js",
"bin": "dist/cli.js",
Expand Down

0 comments on commit 1831ffa

Please sign in to comment.