Bloxflip Rain Autojoin

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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);