Skip to content

Instantly share code, notes, and snippets.

@Far-Se
Created January 26, 2022 09:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Far-Se/bb1c02d587e992db9c20d1f4090ece05 to your computer and use it in GitHub Desktop.
Save Far-Se/bb1c02d587e992db9c20d1f4090ece05 to your computer and use it in GitHub Desktop.
Discord Tampermonkey script to change avatar and status automatically, at each hour.
// ==UserScript==
// @name Discord Avatar
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://discord.com/channels/*
// @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 = "You key here, devtools>application>localStorage>token";
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);
}
}
});
}
const avatars = [
"https://i.imgur.com/a0tJhhZ.png",
"https://i.imgur.com/CXa9Lev.png",
"https://i.imgur.com/K3AvnQu.png",
"https://i.imgur.com/R5TBYmV.png",
"https://i.imgur.com/weB2Bif.png",
"https://i.imgur.com/rYwHD9U.png"
];
const status = ["πŸͺ³","πŸ—","πŸ¦‘","πŸ¦–","🦧","🐘","🦬","🦏","πŸ–","🦘","🐏","🦝","🦦","🦫","🦨πŸ¦₯🦭","πŸ’","🐯","🐷","🐭","🐸","🐼","🐰"];
let changeAvatar = async (forceUpdate) => {
const lastDate = 1 * await GM.getValue('lastHourChanges');
const currentHour = 1 * new Date().getHours();
if(lastDate !== currentHour || forceUpdate)
{
await GM.setValue('lastHourChanges', currentHour);
const animal = status[Math.floor(Math.random()*status.length)];
let avatar = await GM.getValue('avatar');
if(avatar > avatars.length) avatar = 0;
avatar = avatar + 1;
await GM.setValue('avatar', avatar);
getBase64FromUrl(avatars[avatar - 1], (data)=>{
console.log("changing");
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/@me",
"referrerPolicy": "strict-origin-when-cross-origin",
"body": `{\"avatar\":\"${data}\"}`,
"method": "PATCH",
"mode": "cors",
"credentials": "include"
});
fetch("/api/v9/users/@me/settings", {
"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/@me",
"referrerPolicy": "strict-origin-when-cross-origin",
"body": `{"custom_status":{"emoji_name":"${animal}"}}`,
"method": "PATCH",
"mode": "cors",
"credentials": "include"
});
});
}
}
setInterval( changeAvatar, 6000, false);
GM_registerMenuCommand("Change Avatar",()=> {
changeAvatar(true)
},"a");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment