59 lines
2.4 KiB
JavaScript
59 lines
2.4 KiB
JavaScript
// ==UserScript==
|
|
// @name Skinrave Rain Notifier
|
|
// @namespace http://tampermonkey.net/
|
|
// @version 2025-03-03
|
|
// @description Not
|
|
// @author You
|
|
// @match https://skinrave.gg/*
|
|
// @icon https://www.google.com/s2/favicons?sz=64&domain=skinrave.gg
|
|
// @grant none
|
|
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
|
|
// @require https://cdn.jsdelivr.net/gh/CoeJoder/waitForKeyElements.js@v1.3/waitForKeyElements.js
|
|
// @run-at document-end
|
|
// ==/UserScript==
|
|
|
|
const RECHECK_TIMER = 5000;
|
|
const INITIAL_TIMER = 2000;
|
|
const MAIN_WINDOW_SELECTOR = "div.flex.overflow-y-auto.overflow-x-hidden";
|
|
const RAIN_BUTTON_SELECTOR = 'body > div.flex.overflow-y-auto.overflow-x-hidden > div.z-30.fixed.bg-object-bg.border-l.border-gray-90.right-0 > div > div.flex.flex-wrap.gap-2.relative > div.mt-3.w-full.rounded > div > button.relative.z-10.inline-flex.items-center.justify-center.rounded:not(.cursor-not-allowed) > span';
|
|
const RAIN_AMOUNT_SELECTOR = 'body > div.flex.overflow-y-auto.overflow-x-hidden > div.z-30.fixed.bg-object-bg.border-l.border-gray-90.right-0 > div > div.flex.flex-wrap.gap-2.relative > div > div > span > span > span > span';
|
|
|
|
var player = document.createElement('audio');
|
|
player.src = 'https://cdn.pixabay.com/download/audio/2022/03/15/audio_05a708055d.mp3?filename=water-drop-85731.mp3';
|
|
player.preload = 'auto';
|
|
|
|
var title = document.title;
|
|
|
|
function checkRain() {
|
|
let rainJoinButton = $(RAIN_BUTTON_SELECTOR);
|
|
let rainAmount = $(RAIN_AMOUNT_SELECTOR).text();
|
|
var rainTitle = title + ' (Rain: ' +rainAmount + ')';
|
|
if (rainJoinButton.length == 0) {
|
|
console.log('There is no joinable rain');
|
|
setTitle(rainTitle);
|
|
return false;
|
|
}
|
|
console.log('Rain available to join!');
|
|
player.play();
|
|
let blinkTitle = '🌧️ ' + title;
|
|
let emptyTitle = ' ' + title;
|
|
setTitle(blinkTitle);
|
|
let blinkInterval = Math.floor(RECHECK_TIMER / 4);
|
|
setTimeout(() => { setTitle(emptyTitle); }, blinkInterval);
|
|
setTimeout(() => { setTitle(blinkTitle); }, blinkInterval * 2);
|
|
setTimeout(() => { setTitle(emptyTitle); }, blinkInterval * 3);
|
|
}
|
|
|
|
function setTitle(newTitle) {
|
|
document.title = newTitle;
|
|
}
|
|
|
|
function runRoutines() {
|
|
checkRain();
|
|
setTimeout(runRoutines, RECHECK_TIMER);
|
|
}
|
|
|
|
waitForKeyElements(MAIN_WINDOW_SELECTOR, () => {
|
|
title = document.title;
|
|
setTimeout(runRoutines, INITIAL_TIMER);
|
|
}); |