diff --git a/dzunlock.user.js b/dzunlock.user.js index 7f159f9..568a137 100644 --- a/dzunlock.user.js +++ b/dzunlock.user.js @@ -3,7 +3,7 @@ // @namespace io.github.uhwot.dzunlock // @description enables deezer hifi features lol // @author uh wot -// @version 1.3.8 +// @version 1.4.0 // @license GPL-3.0-only // @homepageURL https://git.freezerapp.xyz/uhwot/dzunlock // @downloadURL https://git.freezerapp.xyz/uhwot/dzunlock/raw/branch/master/dzunlock.user.js @@ -95,6 +95,48 @@ window.addEventListener('DOMContentLoaded', (_) => { })(unsafeWindow.dzPlayer.setTrackList); }); +// https://greasyfork.org/en/scripts/38248-websocket-logger/code +unsafeWindow.WebSocket = new Proxy(unsafeWindow.WebSocket, { + construct: function (target, args, _) { + const url = args[0] + const ws = new target(url) + + if (url !== 'wss://messaging.deezer.com/websocket') { + return ws + } else { + log('hooking websocket') + + return new Proxy(ws, { + set: function (target, prop, val) { + if (prop == 'onmessage') { + var onmsg = val; + val = function (e) { + if (e.data.includes('SingleInstancePlayback')) { + log('preventing SingleInstancePlayback pubsub receive') + return + } + onmsg(e) + }; + } + return target[prop] = val + }, + get: function (target, prop) { + var val = target[prop]; + if (prop == 'send') val = function (data) { + if (data.includes('SingleInstancePlayback')) { + log('preventing SingleInstancePlayback pubsub send') + return + } + target.send(data) + }; + else if (typeof val == 'function') val = val.bind(target) + return val + } + }) + } + } +}) + unsafeWindow.fetch = (function (fetch) { return async function (url, init) { if (url === 'https://media.deezer.com/v1/get_url') {