Bloxflip Rain Autojoin

sends notification and plays a sound when a rain event starts and joins it

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Bloxflip Rain Autojoin
// @namespace    http://tampermonkey.net/
// @version      11.0
// @description  sends notification and plays a sound when a rain event starts and joins it
// @author       blueiicey
// @match        https://bflip.com/*
// @icon         https://bflip.com/favicon.ico
// @grant        none
// ==/UserScript==

/*
https://greasyfork.org/en/scripts/493122-bloxflip-auto-rain/code
https://greasyfork.org/en/scripts/447509-bloxflip-spam-blocker/code
https://dashboard.hcaptcha.com/welcome_accessibility
https://nopecha.com/ free tier
*/

//gets notif perms
//console.log("notif perms: "+Notification.permission);
if (Notification.permission === "granted") {
    //don't need to request notif perms
} else if (Notification.permission !== "denied") {
   //get notif perms
    alert("Allow notifications to get notified when a rain occurs")
    Notification.requestPermission().then(permission => {
        console.log(permission)
    });
};


//init var
var activeRain = false;

//checks for rain, alerts user and joins rain
setInterval(async function() {
    //get chat history
    let history = await fetch('https://api.bloxflip.com/chat/history');
    let chat = JSON.parse(await history.text()); //parse it

    if(chat.rain.active && !activeRain) { //check rain status
        var sound = new Audio('https://www.myinstants.com/media/sounds/cash-register-sound-fx.mp3');
        sound.play();
        new Notification(chat.rain.prize.toString() + " R$ Rain", {
            body: "Hosted by " + chat.rain.host
        });
        activeRain = true; //set var
        //click join rain bttn
        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}}
    } else if (!chat.rain.active && activeRain) { //rain stopped
        activeRain = false; //set var
    };
}, 2000);