Xceislor

Open Boxes

Jan 12th, 2022
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. const sleep = (ms) => new Promise(r => setTimeout(r, ms));
  2.  
  3. (async () => {
  4. const box = prompt('What box do you want to open? (EXAMPLE: Space)');
  5. const amount = prompt('How many boxes do you want to open?');
  6.  
  7. const response = await fetch('https://api.blooket.com/api/users/verify-token', { credentials: "include" });
  8. const data = await response.json();
  9.  
  10.  
  11. (new Promise(async (res, rej) => {
  12. var blooks = []
  13. for (let i = 0; i < amount; i++) {
  14. await sleep(100)
  15. fetch('https://api.blooket.com/api/users/unlockblook', {
  16. method: "PUT",
  17. headers: {
  18. "accept": "application/json, text/plain, */*",
  19. "accept-language": "en-US,en;q=0.9,ru;q=0.8",
  20. },
  21. credentials: "include",
  22. body: JSON.stringify({
  23. box: box,
  24. name: data.name,
  25. }),
  26. }).then(r => {
  27. if (r.status == 200) r.json().then(r => blooks.push(r.unlockedBlook))
  28. });
  29. };
  30. res(blooks);
  31. })).then(blooks => {
  32. let count = {};
  33.  
  34. blooks.forEach((i) => { count[i] = (count[i] || 0) + 1; });
  35.  
  36. alert(`Results:\n` + Object.entries(count).map((x) => ` ${x[1]} ${x[0]}`).join(`\n`));
  37. });
  38. })();
Advertisement
Add Comment
Please, Sign In to add comment