Script snippet for use with TamperMonkey.
Last active
March 14, 2023 21:02
-
-
Save diamondburned/ba02d3a2d2f0e9700c832b5684f7634b to your computer and use it in GitHub Desktop.
Discord Websocket injector
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name WS hack | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over Discord! | |
// @author You | |
// @match https://discord.com/* | |
// @grant none | |
// @run-at document-start | |
// @require https://cdnjs.cloudflare.com/ajax/libs/pako/1.0.11/pako.min.js | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function newInflator() { | |
return new pako.Inflate({to: "string", raw: false}); | |
}; | |
const nativeWebSocket = window.WebSocket; | |
window.WebSocket = function(url, ...args) { | |
console.log("INTERJECTED WS: " + url); | |
const socket = new nativeWebSocket(url, ...args); | |
if (!url.includes("gateway.discord.gg")) return socket; | |
let inflator = newInflator(); | |
socket.addEventListener("message", (ev) => { | |
inflator.push(ev.data, 2); | |
console.log("EVENT", JSON.parse(inflator.result)); | |
}); | |
return socket; | |
}; | |
})(); |
Indeed, this doesn't work anymore. I haven't poked around the code base enough to figure out how to fix it.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is currently not working. Have tried multiple ways to intercept WebSocket...