Discord Status Animator (Manual edit/Non-UI)

Automatically changes your Discord status

目前为 2021-06-19 提交的版本。查看 最新版本

  1. ////////////////////////////////////
  2. ///////// Status Animator //////////
  3.  
  4. ////////////////////////////////////
  5. //Settings//////////////////////////
  6.  
  7. var name = "Status Animator";
  8. var version = "V1.8";
  9. var run = true;
  10.  
  11. //This cookie will contain your Token
  12. var cookie_name = "DoNotShareThisToken";
  13. var delete_cookie_after_a_week = true;
  14.  
  15. //Create no cookie, apply the token manually
  16. var manual_discord_token = "";
  17.  
  18. //Your status will be changed to these after you close Discord
  19. var default_status_text = "";
  20. var default_status_emoji = "";
  21. var default_status_state = "online";
  22.  
  23. async function loop() {
  24. ////////////////////////////////////
  25. ////////////////////////////////////
  26. //Your animation code starts here///
  27.  
  28.  
  29. await blink("🥳","I'm using Discord Status Animator!",2000,1);
  30.  
  31. if(await skip(10,"u")) return;
  32.  
  33. await settext("Get it here! Github.com/Hakorr/discord-status-animator");
  34. await wait(5000);
  35.  
  36.  
  37. //Your animation code ends here/////
  38. ////////////////////////////////////
  39. ////////////////////////////////////
  40. }
  41.  
  42.  
  43. /////////////////////////////////////
  44. /* Animation blocks /////////////////
  45. Timeouts are in milliseconds! You can type "random" on the emoji section to randomize it!
  46. - await wait(ms);
  47. - await blank();
  48. - await setstate("state");
  49. -> states = invisible, dnd, idle, online
  50. - await setemoji("emoji");
  51. - await settext("text");
  52. - await status(emoji,text,state);
  53. -> states = invisible, dnd, idle, online
  54. - await typewriter("emoji","text",timeout,reversed);
  55. - await glitch("emoji","text",times,timeout);
  56. - await glitchtype("emoji","text",timeout,glitch_rate,reversed);
  57. - await sentence("emoji","text",timeout);
  58. - await blink("emoji","text",timeout,times);
  59. - await count("emoji","prefix",count_to,"suffix",timeout,reversed);
  60. - if(await skip(1,"unique")) return;
  61. -> The unique string can be anything. If you use two skips, remember to make each one different.
  62. // DO NOT ENTER ZONE - DO NOT ENTER IF YOU DON'T KNOW WHAT TO DO //
  63. /*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
  64. ///////////////////////////////////////////////////////////////////
  65. // DO NOT ENTER ZONE - DO NOT ENTER IF YOU DON'T KNOW WHAT TO DO //
  66.  
  67. // ==UserScript==
  68. // @name Discord Status Animator (Manual edit/Non-UI)
  69. // @namespace https://github.com/Hakorr/discord-status-animator
  70. // @run-at document-start
  71. // @version 1.8
  72. // @description Automatically changes your Discord status
  73. // @author HKR
  74. // @match https://discord.com/discovery
  75. // @match https://discord.com/discovery/*
  76. // @match https://discord.com/store
  77. // @match https://discord.com/store/*
  78. // @match https://discord.com/channels
  79. // @match https://discord.com/channels/*
  80. // @match https://discord.com/app
  81. // @grant none
  82. // ==/UserScript==
  83.  
  84. //Return a random emoji
  85. function random_emoji() {
  86.  
  87. var emojis = [
  88. '😄','😃','😀','😊','😉','😍','😘','😚','😗','😙','😜','😝','😛','😳','😁','😔','😌','😒','😞','😣','😢','😂','😭','😪','😥','😰','😅','😓','😩','😫','😨','😱','😠','😡','😤','😖','😆','😋','😷','😎','😴','😵','😲','😟','😦','😧','😈','👿','😮','😬','😐','😕','😯','😶','😇','😏','😑','👲','👳','👮','👷','💂','👶','👦','👧','👨','👩','👴','👵','👱','👼','👸','😺','😸','😻','😽','😼','🙀','😿','😹','😾','👹','👺','🙈','🙉','🙊','💀','👽','💩','🔥','✨','🌟','💫','💥','💢','💦','💧','💤','💨','👂','👀','👃','👅','👄','👍','👎','👌','👊','✊','✌','👋','✋','👐','👆','👇','👉','👈','🙌','🙏','☝','👏','💪','🚶','🏃','💃','👫','👪','👬','👭','💏','💑','👯','🙆','🙅','💁','🙋','💆','💇','💅','👰','🙎','🙍','🙇','🎩','👑','👒','👟','👞','👡','👠','👢','👕','👔','👚','👗','🎽','👖','👘','👙','💼','👜','👝','👛','👓','🎀','🌂','💄','💛','💙','💜','💚','❤','💔','💗','💓','💕','💖','💞','💘','💌','💋','💍','💎','👤','👥','💬','👣','💭','🐶','🐺','🐱','🐭','🐹','🐰','🐸','🐯','🐨','🐻','🐷','🐽','🐮','🐗','🐵','🐒','🐴','🐑','🐘','🐼','🐧','🐦','🐤','🐥','🐣','🐔','🐍','🐢','🐛','🐝','🐜','🐞','🐌','🐙','🐚','🐠','🐟','🐬','🐳','🐋','🐄','🐏','🐀','🐃','🐅','🐇','🐉','🐎','🐐','🐓','🐕','🐖','🐁','🐂','🐲','🐡','🐊','🐫','🐪','🐆','🐈','🐩','🐾','💐','🌸','🌷','🍀','🌹','🌻','🌺','🍁','🍃','🍂','🌿','🌾','🍄','🌵','🌴','🌲','🌳','🌰','🌱','🌼','🌐','🌞','🌝','🌚','🌑','🌒','🌓','🌔','🌕','🌖','🌗','🌘','🌜','🌛','🌙','🌍','🌎','🌏','🌋','🌌','🌠','⭐','☀','⛅','☁','⚡','☔','❄','⛄','🌀','🌁','🌈','🌊','🎍','💝','🎎','🎒','🎓','🎏','🎆','🎇','🎐','🎑','🎃','👻','🎅','🎄','🎁','🎋','🎉','🎊','🎈','🎌','🔮','🎥','📷','📹','📼','💿','📀','💽','💾','💻','📱','☎','📞','📟','📠','📡','📺','📻','🔊','🔉','🔈','🔇','🔔','🔕','📢','📣','⏳','⌛','⏰','⌚','🔓','🔒','🔏','🔐','🔑','🔎','💡','🔦','🔆','🔅','🔌','🔋','🔍','🛁','🛀','🚿','🚽','🔧','🔩','🔨','🚪','🚬','💣','🔫','🔪','💊','💉','💰','💴','💵','💷','💶','💳','💸','📲','📧','📥','📤','✉','📩','📨','📯','📫','📪','📬','📭','📮','📦','📝','📄','📃','📑','📊','📈','📉','📜','📋','📅','📆','📇','📁','📂','✂','📌','📎','✒','✏','📏','📐','📕','📗','📘','📙','📓','📔','📒','📚','📖','🔖','📛','🔬','🔭','📰','🎨','🎬','🎤','🎧','🎼','🎵','🎶','🎹','🎻','🎺','🎷','🎸','👾','🎮','🃏','🎴','🀄','🎲','🎯','🏈','🏀','⚽','⚾','🎾','🎱','🏉','🎳','⛳','🚵','🚴','🏁','🏇','🏆','🎿','🏂','🏊','🏄','🎣','☕','🍵','🍶','🍼','🍺','🍻','🍸','🍹','🍷','🍴','🍕','🍔','🍟','🍗','🍖','🍝','🍛','🍤','🍱','🍣','🍥','🍙','🍘','🍚','🍜','🍲','🍢','🍡','🍳','🍞','🍩','🍮','🍦','🍨','🍧','🎂','🍰','🍪','🍫','🍬','🍭','🍯','🍎','🍏','🍊','🍋','🍒','🍇','🍉','🍓','🍑','🍈','🍌','🍐','🍍','🍠','🍆','🍅','🌽','🏠','🏡','🏫','🏢','🏣','🏥','🏦','🏪','🏩','🏨','💒','⛪','🏬','🏤','🌇','🌆','🏯','🏰','⛺','🏭','🗼','🗾','🗻','🌄','🌅','🌃','🗽','🌉','🎠','🎡','⛲','🎢','🚢','⛵','🚤','🚣','⚓','🚀','✈','💺','🚁','🚂','🚊','🚉','🚞','🚆','🚄','🚅','🚈','🚇','🚝','🚋','🚃','🚎','🚌','🚍','🚙','🚘','🚗','🚕','🚖','🚛','🚚','🚨','🚓','🚔','🚒','🚑','🚐','🚲','🚡','🚟','🚠','🚜','💈','🚏','🎫','🚦','🚥','⚠','🚧','🔰','⛽','🏮','🎰','♨','🗿','🎪','🎭','📍','🚩','⬆','⬇','⬅','➡','🔠','🔡','🔤','↗','↖','↘','↙','↔','↕','🔄','◀','▶','🔼','🔽','↩','↪','ℹ','⏪','⏩','⏫','⏬','⤵','⤴','🆗','🔀','🔁','🔂','🆕','🆙','🆒','🆓','🆖','📶','🎦','🈁','🈯','🈳','🈵','🈴','🈲','🉐','🈹','🈺','🈶','🈚','🚻','🚹','🚺','🚼','🚾','🚰','🚮','🅿','♿','🚭','🈷','🈸','🈂','Ⓜ','🛂','🛄','🛅','🛃','🉑','㊙','㊗','🆑','🆘','🆔','🚫','🔞','📵','🚯','🚱','🚳','🚷','🚸','⛔','✳','❇','❎','✅','✴','💟','🆚','📳','📴','🅰','🅱','🆎','🅾','💠','➿','♻','♈','♉','♊','♋','♌','♍','♎','♏','♐','♑','♒','♓','⛎','🔯','🏧','💹','💲','💱','©','®','™','〽','〰','🔝','🔚','🔙','🔛','🔜','❌','⭕','❗','❓','❕','❔','🔃','🕛','🕧','🕐','🕜','🕑','🕝','🕒','🕞','🕓','🕟','🕔','🕠','🕕','🕖','🕗','🕘','🕙','🕚','🕡','🕢','🕣','🕤','🕥','🕦','✖','➕','➖','➗','♠','♥','♣','♦','💮','💯','✔','☑','🔘','🔗','➰','🔱','🔲','🔳','◼','◻','◾','◽','▪','▫','🔺','⬜','⬛','⚫','⚪','🔴','🔵','🔻','🔶','🔷','🔸','🔹'
  89. ];
  90.  
  91. return emojis[Math.floor(Math.random() * emojis.length)];
  92. }
  93.  
  94. //Part of user activity function
  95. var is_active = false;
  96. window.onfocus = function() { is_active = true; };
  97. window.onblur = function() { is_active = false; }
  98.  
  99. //Is user on the Discord tab - Return true or false
  100. function activity(positive,negative) {
  101. var return_value = "";
  102. if(is_active) return_value = positive;
  103. else return_value = negative;
  104. return return_value;
  105. }
  106.  
  107. //Output XX/XX/XX @ XX:XX:XX
  108. function getDateTime() {
  109. var currentdate = new Date();
  110.  
  111. if(currentdate.getMinutes() > 9) var fixed_minutes = currentdate.getMinutes();
  112. else var fixed_minutes = "0" + currentdate.getMinutes();
  113. if(currentdate.getSeconds() > 9) var fixed_seconds = currentdate.getSeconds();
  114. else var fixed_seconds = "0" + currentdate.getSeconds();
  115.  
  116. var datetime = currentdate.getDate() + "/" + (currentdate.getMonth()+1) + "/" + currentdate.getFullYear() + " @ " + currentdate.getHours() + ":" + fixed_minutes + ":" + fixed_seconds;
  117.  
  118. return datetime;
  119. }
  120.  
  121. //Output: XX:XX:XX
  122. function getExactTime() {
  123. var currentdate = new Date();
  124.  
  125. if(currentdate.getMinutes() > 9) var fixed_minutes = currentdate.getMinutes();
  126. else var fixed_minutes = "0" + currentdate.getMinutes();
  127. if(currentdate.getSeconds() > 9) var fixed_seconds = currentdate.getSeconds();
  128. else var fixed_seconds = "0" + currentdate.getSeconds();
  129.  
  130. var datetime = currentdate.getHours() + ":" + fixed_minutes + ":" + fixed_seconds;
  131.  
  132. return datetime;
  133. }
  134.  
  135. //Output: XX:XX
  136. function getTime() {
  137. var currentdate = new Date();
  138.  
  139. if(currentdate.getMinutes() > 9) var fixed_minutes = currentdate.getMinutes();
  140. else var fixed_minutes = "0" + currentdate.getMinutes();
  141.  
  142. var datetime = currentdate.getHours() + ":" + fixed_minutes;
  143.  
  144. return datetime;
  145. }
  146.  
  147. //Simple wait function for animation
  148. function wait(t) {
  149. return new Promise(function(resolve) {
  150. setTimeout(resolve, t)
  151. });
  152. }
  153.  
  154. //Typewriter effect
  155. async function typewriter(emoji,text,timeout,reversed) {
  156. //Repeat for each letter
  157. for(var i = 1; i <= text.length; i++) {
  158. //Cut the text
  159. if(!reversed) var substring_text = text.substring(0,i);
  160. else var substring_text = text.substring(0,text.length - i);
  161. //Set the status to the cutted text
  162. if(emoji != "random") await status(emoji,substring_text);
  163. else await status(random_emoji(),substring_text);
  164. //Wait a selected amount of time until writing the next letter
  165. await wait(timeout);
  166. }
  167.  
  168. return;
  169. }
  170.  
  171. //Glitch effect
  172. async function glitch(emoji,text,times,timeout) {
  173. //Repeat for each letter
  174. for(var i = 1; i < times; i++) {
  175. //Shuffle the text
  176. var glitch_text = shuffle(text)
  177. //Set the status to the cutted text
  178. if(emoji != "random") await status(emoji,glitch_text);
  179. else await status(random_emoji(),glitch_text);
  180. //Wait a selected amount of time until writing the next letter
  181. await wait(timeout);
  182. }
  183.  
  184. return;
  185. }
  186.  
  187. //Glitchtype effect
  188. async function glitchtype(emoji,text,timeout,glitch_rate,reversed) {
  189. //Repeat for each letter
  190. for(var i = 1; i <= text.length; i++) {
  191. //Cut the text
  192. if(!reversed) var substring_text = text.substring(0,i);
  193. else var substring_text = text.substring(0,text.length - i);
  194. //Glitch rest of the text
  195. if(!reversed) var glitch_text = shuffle(text.substring(i));
  196. else var glitch_text = shuffle(text.substring(text.length - i));
  197. //Set the status to the cutted text + glitched text
  198. if(emoji != "random") await status(emoji,substring_text + glitch_text);
  199. else await status(random_emoji(),substring_text + glitch_text);
  200. //Wait a selected amount of time until writing the next letter
  201. await wait(timeout);
  202. for(var a = 0; a < glitch_rate; a++) {
  203. //Glitch rest of the text
  204. if(!reversed) var glitch_text = shuffle(text.substring(i));
  205. else var glitch_text = shuffle(text.substring(text.length - i));
  206. //Set the status to the cutted text + glitched text
  207. await status(emoji,substring_text + glitch_text);
  208. //Wait a selected amount of time until writing the next glitched characterset at the end of the string
  209. await wait(timeout/2);
  210. }
  211. }
  212. return;
  213. }
  214.  
  215. //Sentence effect
  216. async function sentence(emoji,text,timeout) {
  217. //Split sentence into words
  218. var words = text.split(" ");
  219.  
  220. //Repeat for each word
  221. for(var i = 0; i < words.length; i++) {
  222. //Set status to array's word
  223. if(emoji != "random") await status(emoji,words[i]);
  224. else await status(random_emoji(),words[i]);
  225. //Wait a selected amount of time until writing the next letter
  226. await wait(timeout);
  227. }
  228. return;
  229. }
  230.  
  231. //Blink effect
  232. async function blink(emoji,text,timeout,times) {
  233. for(var i = 0; i < times; i++) {
  234. if(emoji != "random") await status(emoji,text);
  235. else await status(random_emoji(),text);
  236. await wait(timeout);
  237. await blank();
  238. await wait(timeout);
  239. }
  240.  
  241. return;
  242. }
  243.  
  244. //Clear the status
  245. async function blank() {
  246. //Could just send blank status as {"custom_status":null}, but that behaves weirdly.
  247. await status("","");
  248.  
  249. return;
  250. }
  251.  
  252.  
  253. //Part of the skip function - stackoverflow.com/a/8630472
  254. var store = (function() {
  255. var map = {};
  256.  
  257. return {
  258. set: function ( name, value ) {
  259. map[ name ] = value;
  260. },
  261. get: function ( name ) {
  262. return map[ name ];
  263. }
  264. };
  265. })();
  266.  
  267. //Skip the end of the animation
  268. async function skip(amount,uniquetext) {
  269. var uniqueID = amount + "_" + uniquetext;
  270.  
  271. var set = store.set;
  272. var get = store.get;
  273. var currentamount = get(uniqueID);
  274.  
  275. //Check if there's a variable already
  276. if(currentamount >= 0) {
  277. //If to continue
  278. if(currentamount == amount) {
  279. //Reset the variable
  280. set(uniqueID,0);
  281. //Update the currentamount variable
  282. currentamount = get(uniqueID);
  283. //console.log("id: " + uniqueID + "\n\n value: " + get(uniqueID) + " | result: false\n\n");
  284. return false;
  285. }
  286. //Skip
  287. else {
  288. //Add one to the variable
  289. set(uniqueID,get(uniqueID) + 1);
  290. //Update the currentamount variable
  291. currentamount = get(uniqueID);
  292. //console.log("id: " + uniqueID + "\n\n value: " + get(uniqueID) + " | result: true\n\n");
  293. return true;
  294. }
  295. //If there was no variable made already
  296. } else {
  297. //Make the variable
  298. set(uniqueID,0);
  299. //Add one to it
  300. set(uniqueID,get(uniqueID) + 1);
  301. //Update the currentamount variable
  302. currentamount = get(uniqueID);
  303. //console.log("(FIRST TIME) " + "id: " + uniqueID + "\n\n value: " + get(uniqueID) + " | result: true\n\n");
  304. return true;
  305. }
  306. }
  307.  
  308. //Count effect
  309. async function count(emoji,prefix,count_to,suffix,timeout,reversed) {
  310. for(var i = 0; i < count_to; i++) {
  311. if(!reversed) {
  312. var recalculated_count = i + 1;
  313. var final_string = prefix + recalculated_count + suffix;
  314. }
  315. else {
  316. var recalculated_count = count_to - i;
  317. var final_string = prefix + recalculated_count + suffix;
  318. }
  319. if(emoji != "random") await status(emoji,final_string);
  320. else await status(random_emoji(),final_string);
  321. await wait(timeout);
  322. }
  323. return;
  324. }
  325.  
  326. //Generate random number between min and max
  327. function random_number(min,max) {
  328. return Math.floor(Math.random() * (max - min + 1)) + min;
  329. }
  330.  
  331. //codespeedy.com/shuffle-characters-of-a-string-in-javascript/
  332. function getRandomInt(n) {
  333. return Math.floor(Math.random() * n);
  334. }
  335.  
  336. //codespeedy.com/shuffle-characters-of-a-string-in-javascript/
  337. function shuffle(s) {
  338. var arr = s.split(''); // Convert String to array
  339. var n = arr.length; // Length of the array
  340.  
  341. for(var i=0 ; i<n-1 ; ++i) {
  342. var j = getRandomInt(n); // Get random of [0, n-1]
  343.  
  344. var temp = arr[i]; // Swap arr[i] and arr[j]
  345. arr[i] = arr[j];
  346. arr[j] = temp;
  347. }
  348.  
  349. s = arr.join(''); // Convert Array to string
  350. return s; // Return shuffled string
  351. }
  352.  
  353. //Function to read the saved cookie
  354. window.getCookie = function(name) {
  355. var match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
  356. if (match) return match[2];
  357. }
  358.  
  359. //If user has set their Token manually
  360. if(manual_discord_token.length > 0) token = manual_discord_token;
  361. else {
  362. //Set the Discord Token as a Cookie for future use of the script
  363. //If there is no Token cookie
  364. if(document.cookie.indexOf(cookie_name + "=") == -1) {
  365. //Ask user if they want to refresh the page to get the token
  366. if(confirm("\"" + cookie_name + "\" cookie not found. Refreshing Discord to get it.\n\n- " + name + " " + version)) {
  367. //Load the page again and create a new element which will have the token in its localStorage
  368. location.reload();
  369. var i = document.createElement('iframe');
  370. document.body.appendChild(i);
  371. //Get Token from localStorage
  372. var token = i.contentWindow.localStorage.token
  373. token = token.slice(1, -1);
  374. //Delete cookie after a week or not
  375. if(delete_cookie_after_a_week)
  376. document.cookie = cookie_name + "=" + token + "; secure=true; max-age=604800; path=/";
  377. else
  378. document.cookie = cookie_name + "=" + token + "; secure=true; path=/";
  379.  
  380. } else throw new Error("[Not an actually uncaught] User stopped the Status Animator. \n\nNo cookie was found and user decided not to continue.");
  381. }
  382. }
  383.  
  384.  
  385. var status_text = "";
  386. var status_emoji = "";
  387. var status_state = "";
  388. //Function that changes the status variables (Saves up a bit space)
  389. async function status(emoji,text,state) {
  390. if(run) {
  391. status_text = text;
  392. status_emoji = emoji;
  393. status_state = state;
  394. await setstatus();
  395. return;
  396. }
  397. }
  398.  
  399. //Get Discord Token from saved Cookie
  400. if(manual_discord_token.length > 0) var token = manual_discord_token;
  401. else var token = getCookie(cookie_name);
  402.  
  403. //HTTP Request's URL address
  404. var url = "https://discord.com/api/v9/users/@me/settings";
  405.  
  406. //Function that handles the HTTP request for the status change
  407. async function setstatus() {
  408.  
  409. var request = new XMLHttpRequest();
  410. request.open("PATCH", url);
  411. request.setRequestHeader("Accept", "*/*" );
  412. request.setRequestHeader("Content-Type", "application/json");
  413. request.setRequestHeader("Authorization", token);
  414. request.send(JSON.stringify({"custom_status":{"text":status_text,"emoji_name":status_emoji}}));
  415.  
  416. //If the request failed
  417. request.onreadystatechange = () => {
  418. if (request.status != 200) {
  419. run = false;
  420. throw new Error("[Not an actually uncaught] Failed to update status. \n\nThe HTTP request failed. Most likely because the authorization token is incorrect.");
  421. }
  422. };
  423.  
  424. if(status_state == "invisible" || status_state == "dnd" || status_state == "idle" || status_state == "online") {
  425. var request2 = new XMLHttpRequest();
  426. request2.open("PATCH", url);
  427. request2.setRequestHeader("Accept", "*/*" );
  428. request2.setRequestHeader("Content-Type", "application/json");
  429. request2.setRequestHeader("Authorization", token);
  430. request2.send(JSON.stringify({"status":status_state}));
  431. //If the request failed
  432. request2.onreadystatechange = () => {
  433. if (request2.status != 200) {
  434. run = false;
  435. throw new Error("[Not an actually uncaught] Failed to update status. \n\nThe HTTP request failed. Most likely because the authorization token is incorrect.");
  436. }
  437. };
  438. }
  439.  
  440. return;
  441. }
  442.  
  443. async function setstate(text) {
  444. if(run) {
  445. status_state = text;
  446. if(status_state == "invisible" || status_state == "dnd" || status_state == "idle" || status_state == "online") {
  447. var request = new XMLHttpRequest();
  448. request.open("PATCH", url);
  449. request.setRequestHeader("Accept", "*/*" );
  450. request.setRequestHeader("Content-Type", "application/json");
  451. request.setRequestHeader("Authorization", token);
  452. request.send(JSON.stringify({"status":status_state}));
  453. //If the request failed
  454. request.onreadystatechange = () => {
  455. if (request.status != 200) {
  456. run = false;
  457. throw new Error("[Not an actually uncaught] Failed to update state. \n\nThe HTTP request failed. Most likely because the authorization token is incorrect.");
  458. }
  459. };
  460. }
  461.  
  462. return;
  463. }
  464. }
  465.  
  466. async function setemoji(emoji) {
  467. if(run) {
  468. status_emoji = emoji;
  469. var request = new XMLHttpRequest();
  470. request.open("PATCH", url);
  471. request.setRequestHeader("Accept", "*/*" );
  472. request.setRequestHeader("Content-Type", "application/json");
  473. request.setRequestHeader("Authorization", token);
  474. request.send(JSON.stringify({"custom_status":{"emoji_name":status_emoji}}));
  475.  
  476. //If the request failed
  477. request.onreadystatechange = () => {
  478. if (request.status != 200) {
  479. run = false;
  480. throw new Error("[Not an actually uncaught] Failed to update emoji. \n\nThe HTTP request failed. Most likely because the authorization token is incorrect.");
  481. }
  482. };
  483.  
  484. return;
  485. }
  486. }
  487.  
  488. async function settext(text) {
  489. if(run) {
  490. status_text = text;
  491. var request = new XMLHttpRequest();
  492. request.open("PATCH", url);
  493. request.setRequestHeader("Accept", "*/*" );
  494. request.setRequestHeader("Content-Type", "application/json");
  495. request.setRequestHeader("Authorization", token);
  496. request.send(JSON.stringify({"custom_status":{"text":status_text}}));
  497.  
  498. //If the request failed
  499. request.onreadystatechange = () => {
  500. if (request.status != 200) {
  501. run = false;
  502. throw new Error("[Not an actually uncaught] Failed to update text. \n\nThe HTTP request failed. Most likely because the authorization token is incorrect.");
  503. }
  504. };
  505.  
  506. return;
  507. }
  508. }
  509.  
  510. //Loops the animation
  511. async function animation_loop() {
  512. while(run) {
  513. await loop();
  514. }
  515. }
  516.  
  517. //Start the animation loop
  518. animation_loop();
  519.  
  520. //Edit/Clear status before exiting
  521. window.onbeforeunload = function () {
  522. run = false;
  523.  
  524. status_text = default_status_text;
  525. status_emoji = default_status_emoji;
  526.  
  527. if(status_state == "invisible" || status_state == "dnd" || status_state == "idle" || status_state == "online")
  528. status_state = default_status_state;
  529.  
  530. setstatus();
  531.  
  532. return "";
  533. };

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址