BloxFlip Rain Notification

Makes a sound when rain

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         BloxFlip Rain Notification
// @name:ru      BloxFlip Уведомление на дожди
// @namespace    http://tampermonkey.net/
// @version      0.6
// @description  Makes a sound when rain
// @description:ru  Издает звук когда начинается дождь
// @author       HProgram
// @match        https://bloxflip.com/*
// @icon         https://i.imgur.com/U8U9VYV.png
// @license GPL-3.0-only
// ==/UserScript==

// Discord: Serzh1204#9186

let isRaining = false;

function sleep(milliseconds) {
  const date = Date.now();
  let currentDate = null;
  do {
    currentDate = Date.now();
  } while (currentDate - date < milliseconds);
}

function playSound() {
  let audio = new Audio('https://www.myinstants.com/media/sounds/bepbob.mp3');
audio.muted = true;
sleep(1000);
audio.muted = false;
  audio.play();
}


setInterval(async function() {
  let history = await fetch('https://api.bloxflip.com/chat/history');
  let historyJson = JSON.parse(await history.text());

  if (historyJson.rain.active && !isRaining) {
    playSound();
    isRaining = true;
  } else if (!historyJson.rain.active && isRaining) {
    isRaining = false;
  }
}, 5000);