Skip to content

Instantly share code, notes, and snippets.

@Far-Se
Last active August 1, 2023 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Far-Se/9b31ff066eb6837f42268040fb40c9bc to your computer and use it in GitHub Desktop.
Save Far-Se/9b31ff066eb6837f42268040fb40c9bc to your computer and use it in GitHub Desktop.
Discord mimic user name and avatar.
// ==UserScript==
// @name Discord Mimic
// @namespace Discord
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://discord.com/*
// @icon https://t1.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=http://discord.com
// @grant GM_xmlhttpRequest
// @grant GM.setValue
// @grant GM.getValue
// @grant GM_registerMenuCommand
// ==/UserScript==
const DISCORD_TOKEN = "TOKEN_HERE";
const getBase64FromUrl = (url,cb) => {
GM_xmlhttpRequest({
method: "GET",
url: url,
responseType: "blob",
onload: function(response) {
var blob = new Blob([this.response], {type: 'image/png'});
var fileReader = new window.FileReader();
fileReader.readAsDataURL(blob);
fileReader.onloadend = function() {
cb(fileReader.result);
}
}
});
}
let stealUser = (reset) => {
let hover = document.querySelectorAll(":hover");
let el = hover[hover.length-1].closest('li');
let avatar = el.querySelector('img[class*="avatar"]').getAttribute('src').replace('80','480');
let user = el.querySelector('h3 span[id]').innerText;
if(reset) {
user = "Your Username";
avatar = "https://avatar.link/image.png";
}
getBase64FromUrl(avatar, (data)=>{
console.log("changing");
//avatar
fetch("/api/v9/users/@me", {
"headers": {
"accept": "*/*",
"accept-language": "en-US,en;q=0.9,ro;q=0.8,hu;q=0.7,fr;q=0.6,bg;q=0.5,it;q=0.4,de;q=0.3",
"authorization": DISCORD_TOKEN,
"content-type": "application/json",
"sec-ch-ua": "\" Not;A Brand\";v=\"99\", \"Google Chrome\";v=\"97\", \"Chromium\";v=\"97\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"Windows\"",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"x-debug-options": "bugReporterEnabled",
"x-discord-locale": "en-US",
},
"referrer": "https://discord.com/channels/484640057764872193/879435428682432542",
"referrerPolicy": "strict-origin-when-cross-origin",
"body": `{\"global_name\":\"${user}\",\"avatar\":\"${data}\"}`,
"method": "PATCH",
"mode": "cors",
"credentials": "include"
});
});
}
GM_registerMenuCommand("Mimic User",()=> {
setTimeout( () => stealUser(),500);
},"m");
GM_registerMenuCommand("Reset User",()=> {
setTimeout( () => stealUser(true),500);
},"r");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment