Bloxflip Rain Autojoin
Wrap lines
1. // ==UserScript==
2. // @name Bloxflip Rain Autojoin
3. // @namespace http://tampermonkey.net/
4. // @version 11.0
5. // @description sends notification and plays a sound when a rain event starts and joins it
6. // @author blueiicey
7. // @match https://bflip.com/*
8. // @icon https://bflip.com/favicon.ico
9. // @grant none
10. // ==/UserScript==
12. /*
13. https://greasyfork.org/en/scripts/493122-bloxflip-auto-rain/code
14. https://greasyfork.org/en/scripts/447509-bloxflip-spam-blocker/code
15. https://dashboard.hcaptcha.com/welcome_accessibility
16. https://nopecha.com/ free tier
17. */
19. //gets notif perms
20. //console.log("notif perms: "+Notification.permission);
21. if (Notification.permission === "granted") {
22. //don't need to request notif perms
23. } else if (Notification.permission !== "denied") {
24. //get notif perms
25. alert("Allow notifications to get notified when a rain occurs")
26. Notification.requestPermission().then(permission => {
27. console.log(permission)
28. });
29. };
32. //init var
33. var activeRain = false;
35. //checks for rain, alerts user and joins rain
36. setInterval(async function() {
37. //get chat history
38. let history = await fetch('https://api.bloxflip.com/chat/history');
39. let chat = JSON.parse(await history.text()); //parse it
41. if(chat.rain.active && !activeRain) { //check rain status
42. var sound = new Audio('https://www.myinstants.com/media/sounds/cash-register-sound-fx.mp3');
43. sound.play();
44. new Notification(chat.rain.prize.toString() + " R$ Rain", {
45. body: "Hosted by " + chat.rain.host
46. });
47. activeRain = true; //set var
48. //click join rain bttn
49. const b=document.querySelectorAll('div[class*="chatBanner"]');for(const a of b){const p=a.querySelectorAll('p');for(const c of p)if(c.textContent.trim()==='Join For Free'){c.click();break}}
50. } else if (!chat.rain.active && activeRain) { //rain stopped
51. activeRain = false; //set var
52. };
53. }, 2000);
License:
CC BY 4.0