Created
March 10, 2024 02:17
-
-
Save e9x/b40c42dc5e5b3292674e45a524a4bd60 to your computer and use it in GitHub Desktop.
Prevent others from knowing you're typing on Discord
This file contains 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 Discord Block Typing | |
// @namespace https://github.com/e9x | |
// @version 1.0.0 | |
// @description Prevent others from knowing you're typing on Discord | |
// @author e9x | |
// @homepageURL https://github.com/e9x | |
// @match https://*.discord.com/app | |
// @match https://*.discord.com/channels/* | |
// @match https://*.discord.com/login | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=discord.com | |
// @grant none | |
// @run-at document-start | |
// ==/UserScript== | |
const { open, send } = XMLHttpRequest.prototype; | |
const blockReqs = new WeakSet(); | |
XMLHttpRequest.prototype.open = function ( | |
method, | |
url, | |
async, | |
username, | |
password | |
) { | |
const parsedURL = new URL(url, location.toString()); | |
if ( | |
parsedURL.host === location.host && | |
/^\/api\/v\d+\/channels\/\d+\/typing$/.test(parsedURL.pathname) | |
) { | |
blockReqs.add(this); | |
} | |
return open.call(this, method, url, async, username, password); | |
}; | |
XMLHttpRequest.prototype.send = function (body) { | |
send.call(this, body); | |
if (blockReqs.has(this)) this.abort(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment