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

Automatically changes your Discord status

目前为 2021-07-22 提交的版本。查看 最新版本

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

QingJ © 2025

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