// ==UserScript== // @name Discord Status Animator (Manual edit/Non-UI) // @namespace https://github.com/Hakorr/status-animator // @run-at document-start // @version 1.3 // @description Automatically changes your Discord status // @author HKR // @match https://discord.com/* // @grant none // @downloadURL none // ==/UserScript== (function() { //Welcome! Don't be scared by the code, I was too lazy to do an UI for this. //All you have to edit is the statusanimation function's code (Around the line 40) var name = "Status Animator"; var version = "V1.3"; var run = true; //A Cookie will be made with this name, feel free to edit it var cookie_name = "StatusToken"; var delete_cookie_after_a_week = true; //Your status will be changed to these after you close the Discord tab var default_status_text = ""; var default_status_emoji = ""; var default_status_state = "online"; //Animation blocks//////////////// /* - await delay(ms); - await status(emoji,text,state); -> states = invisible, dnd, idle, online - await typewriter("text",timeout); - await glitch("text",times,timeout); - await glitchtype("text",timeout,glitch_rate); - await sentence("text",timeout); */async function statusanimation() { //////////////////////////////////// //This is your animation code/////// await status("👐","This","online"); await delay(500); await status("👀","Is","dnd"); await delay(500); await status("😶","A","idle"); await delay(500); await status("✨","Test","invisible"); await delay(500); await status("","","online"); await delay(500); await typewriter("It's just a test!",100); await typewriter("It's just a test!",100,true); await delay(500); await glitch("I am just testing this!",25,100); await glitchtype("I am just testing this!",100,3); await delay(2000); await sentence("Cats are more lazy than dogs",500); await delay(500); await status("",""); await delay(5000); ///////////////////////////// //This loops the animation if (run) statusanimation(); } //Do not edit after this line (If you don't know what you're doing) /////////////////////////////////////////////////////////////////// //Simple delay function for animation function delay(t) { return new Promise(function(resolve) { setTimeout(resolve, t) }); } //Typewriter effect async function typewriter(text,timeout,reversed) { //Repeat for each letter for(var i = 1; i <= text.length; i++) { //Cut the text if(!reversed) var substring_text = text.substring(0,i); else var substring_text = text.substring(0,text.length - i); //Set the status to the cutted text await status("",substring_text); //Wait a selected amount of time until writing the next letter await delay(timeout); } return; } //Glitch effect async function glitch(text,times,timeout) { //Repeat for each letter for(var i = 1; i < times; i++) { //Shuffle the text var glitch_text = shuffle(text) //Set the status to the cutted text await status("",glitch_text); //Wait a selected amount of time until writing the next letter await delay(timeout); } return; } //Glitchtype effect async function glitchtype(text,timeout, glitch_rate) { //Repeat for each letter for(var i = 1; i <= text.length; i++) { //Cut the text var substring_text = text.substring(0,i); //Glitch rest of the text var glitch_text = shuffle(text.substring(i)); //Set the status to the cutted text + glitched text await status("",substring_text + glitch_text); //Wait a selected amount of time until writing the next letter await delay(timeout); for(var a = 0; a < glitch_rate; a++) { //Glitch rest of the text glitch_text = shuffle(text.substring(i)); //Set the status to the cutted text + glitched text await status("",substring_text + glitch_text); //Wait a selected amount of time until writing the next glitched characterset at the end of the string await delay(100); } } return; } async function sentence(text,timeout) { //Split sentence into words var words = text.split(" "); //Repeat for each word for(var i = 0; i < words.length; i++) { //Set status to array's word await status("",words[i]); //Wait a selected amount of time until writing the next letter await delay(timeout); } return; } //codespeedy.com/shuffle-characters-of-a-string-in-javascript/ function getRandomInt(n) { return Math.floor(Math.random() * n); } //codespeedy.com/shuffle-characters-of-a-string-in-javascript/ function shuffle(s) { var arr = s.split(''); // Convert String to array var n = arr.length; // Length of the array for(var i=0 ; i { if (request.status != 200) { run = false; throw new Error("[Not an actually uncaught] Failed to update status. \n\nThe HTTP request failed. Most likely because the authorization token is incorrect."); } }; if(status_state == "invisible" || status_state == "dnd" || status_state == "idle" || status_state == "online") { var request2 = new XMLHttpRequest(); request2.open("PATCH", url); request2.setRequestHeader("Accept", "*/*" ); request2.setRequestHeader("Content-Type", "application/json"); request2.setRequestHeader("Authorization", token); request2.send(JSON.stringify({"status":status_state})); //If the request failed request2.onreadystatechange = () => { if (request2.status != 200) { run = false; throw new Error("[Not an actually uncaught] Failed to update status. \n\nThe HTTP request failed. Most likely because the authorization token is incorrect."); } }; } return; } //Start the animation for the first time if (run) statusanimation(); //Edit (Clear by default) status before exiting window.onbeforeunload = function () { run = false; status_text = default_status_text; status_emoji = default_status_emoji; if(status_state == "invisible" || status_state == "dnd" || status_state == "idle" || status_state == "online") status_state = default_status_state; setstatus(); return ""; }; })();