forked from cybercase/webminidisc
-
Notifications
You must be signed in to change notification settings - Fork 28
/
webminidisc-song-recognition.user.js
30 lines (29 loc) · 1.11 KB
/
webminidisc-song-recognition.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// ==UserScript==
// @name Web Minidisc Song Recognition Enabler
// @description This userscript lets you use the Song Recognition functionality of Web Minidisc Pro without ElectronWMD
// @version 0.1.0
// @namespace http://tampermonkey.net/
// @author Asivery
// @match https://web.minidisc.wiki/
// @grant GM.xmlHttpRequest
// @grant unsafeWindow
// @run-at document-start
// @connect amp.shazam.com
// ==/UserScript==
(function() {
'use strict';
unsafeWindow.native = {
unrestrictedFetchJSON: (url, parameters = {}) => new Promise((res, rej) => {
GM.xmlHttpRequest({
method: parameters.method ?? "GET",
url,
data: parameters.body ?? "",
headers: parameters.headers ?? { "Content-Type": "application/json" },
onload: response =>
res(JSON.parse(response.responseText)),
onerror: error =>
rej(error)
})
})};
console.log("[Userscript]: Attached ElectronWMD's fetch method successfully!");
})();