Skip to content

Instantly share code, notes, and snippets.

@meowabyte
Last active July 16, 2024 18:48
Show Gist options
  • Save meowabyte/11d7ca9631e76a75acdd6a91ce4f3a89 to your computer and use it in GitHub Desktop.
Save meowabyte/11d7ca9631e76a75acdd6a91ce4f3a89 to your computer and use it in GitHub Desktop.
A fairly simple snippet for MessageLatency plugin manipulation for Vencord. It doesn't use any Vencord-depending variables so you can use Vanilla Discord to troll others
;(async () => {
if(location.hostname !== "discord.com") return console.log(
"%cPlease run this snippet on Discord!",
"color: red; background-color: black; padding: 5px; font-weight: bold;"
)
if(window.__LOADED_MESSAGELATENCY_MANIPULATOR == true) return console.log(
"%cYou can only run this snippet once! If you want to change latency, run _changeLatency()!",
"color: red; background-color: black; padding: 5px; font-weight: bold;"
)
else Object.defineProperty(window, "__LOADED_MESSAGELATENCY_MANIPULATOR", { value: true, configurable: false, enumerable: false, writable: false })
console.log("%cSetting up snippet...", "color: gray;")
const nonceShift = 14200704e5
const fromNonce = val => Math.floor(Number(val) / 4194304) + nonceShift
const toNonce = val => {
let t = val - nonceShift;
return t <= 0 ? "0" : (BigInt(t) << 22n).toString()
}
let daysDelay = 1337
window._changeLatency = () => {
let val = null
while ( val === null ) {
const t = prompt(`New delay value? (Current value: ${daysDelay}) | Type "exit" to cancel`)
if(t === "exit") return
val = parseInt(t) || null
}
daysDelay = val;
}
window._XMLHttpRequest = window._XMLHttpRequest || window.XMLHttpRequest
window.XMLHttpRequest = class extends window._XMLHttpRequest {
open(method, url) {
this._shouldManipulateNonce = /https:\/\/discord.com\/api\/v\d\/channels\/\d+\/messages/.test(url) && method === "POST"
return super.open(...arguments)
}
get responseText() {
let t = super.responseText;
if(this._shouldManipulateNonce) {
const json = JSON.parse(t);
json.nonce = this._originalNonce;
t = JSON.stringify(json)
}
return t;
}
send(body) {
if(this._shouldManipulateNonce) {
const json = JSON.parse(body)
this._originalNonce = json.nonce
json.nonce = toNonce(fromNonce(json.nonce) - (daysDelay * 86400000))
body = JSON.stringify(json);
}
return super.send(body)
}
}
console.log(
`%cLoaded properly! If you ever gonna need to change latency just run %c_changeLatency()%c in console! To remove snippet restart Discord.%c\n%c🟡 Some messages might show duplicated! But it's just client-side.`,
"color: #00ff02; background-color: black; padding: 5px;",
"color: #00ff02; background-color: black; padding: 5px; font-weight: bold;",
"color: #00ff02; background-color: black; padding: 5px;",
"",
"color: yellow; background-color: black; padding: 5px; font-weight: bold;"
)
})();
@RODIOMG7
Copy link

i need this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment