[Discord] Status Animator (Manual edit/Non-UI)

Automatically changes your Discord status

当前为 2021-07-22 提交的版本,查看 最新版本

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

QingJ © 2025

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