diff --git a/dzunlock.user.js b/dzunlock.user.js index 673a0a3..c2c3a0c 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.4.4 +// @version 1.4.5 // @license GPL-3.0-only // @homepageURL https://git.uhwot.cf/uhwot/dzunlock // @downloadURL https://uhwotgit.fly.dev/uhwot/dzunlock/raw/branch/master/dzunlock.user.js @@ -101,39 +101,39 @@ unsafeWindow.WebSocket = new Proxy(unsafeWindow.WebSocket, { const url = args[0] const ws = new target(url) - if (url !== 'wss://messaging.deezer.com/websocket') { + if (!url.startsWith('wss://live.deezer.com/ws/')) { 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') + log('hooking websocket') + + return new Proxy(ws, { + set: function (target, prop, val) { + return target[prop] = val + }, + get: function (target, prop) { + var val = target[prop]; + if (prop == 'send') val = function (data) { + const json = JSON.parse(data) + log(json) + const [ msgType, subId ] = json + if (subId.endsWith('_STREAM')) { + if (msgType === 'sub') { + log('preventing play action subscription') return } - target.send(data) - }; - else if (typeof val == 'function') val = val.bind(target) - return val - } - }) - } + if (msgType === 'send') { + log('preventing play action publish') + return + } + } + + target.send(data) + }; + else if (typeof val == 'function') val = val.bind(target) + return val + } + }) } })