From dbf97a20ce768e2438535d9b94bafbbf8f02a73a Mon Sep 17 00:00:00 2001 From: Valentine <111288675+valxe@users.noreply.github.com> Date: Mon, 12 Aug 2024 21:03:51 +0200 Subject: [PATCH] Create bloxflip-notifier.user.js --- bloxflip-notifier.user.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 bloxflip-notifier.user.js diff --git a/bloxflip-notifier.user.js b/bloxflip-notifier.user.js new file mode 100644 index 0000000..11532ae --- /dev/null +++ b/bloxflip-notifier.user.js @@ -0,0 +1,37 @@ +// ==UserScript== +// @name Bloxflip Rain Notifier +// @namespace http://tampermonkey.net/ +// @version 1.0.2 +// @description Notify about rain ! +// @author Valentineuh +// @match https://bloxflip.com/* +// @icon https://bloxflip.com/favicon.ico +// @license MIT +// @grant GM_xmlhttpRequest +// ==/UserScript== + +window.addEventListener('load', () => { + + let raining = false; + + if (Notification.permission !== 'granted') { + Notification.requestPermission(); + } + + setInterval(async () => { + let data = await (await fetch('https://api.bloxflip.com/chat/history')).json(); + let prize = data.rain.prize + if (data.rain.active && !raining) { + if (Notification.permission === 'granted') { + new Notification("Rain detected! 😋", { + body: `Rain has started yeppie!! Prize : ${prize} bobux.`, + icon: 'https://raw.githubusercontent.com/valxe/bloxflip-rain-joiner/main/icone.png' + }); + } + raining = true; + + } else if (!data.rain.active && raining) { + raining = false; + } + }, 5000); +});