Refactoring, change favicon on blink
This commit is contained in:
parent
68df40a848
commit
a4fa573179
@ -1,9 +1,9 @@
|
||||
// ==UserScript==
|
||||
// @name Skinrave Rain Notifier
|
||||
// @namespace http://tampermonkey.net/
|
||||
// @version 2025-03-03
|
||||
// @version 2025-03-05
|
||||
// @description Not
|
||||
// @author You
|
||||
// @author Abhorrent_Anger
|
||||
// @match https://skinrave.gg/*
|
||||
// @icon https://www.google.com/s2/favicons?sz=64&domain=skinrave.gg
|
||||
// @grant none
|
||||
@ -23,31 +23,50 @@ player.src = 'https://cdn.pixabay.com/download/audio/2022/03/15/audio_05a708055d
|
||||
player.preload = 'auto';
|
||||
|
||||
var title = document.title;
|
||||
var rainTitle = title;
|
||||
|
||||
function checkRain() {
|
||||
let rainJoinButton = $(RAIN_BUTTON_SELECTOR);
|
||||
let rainAmount = $(RAIN_AMOUNT_SELECTOR).text();
|
||||
var rainTitle = title + ' (Rain: ' +rainAmount + ')';
|
||||
rainTitle = title + ' (Rain: ' + rainAmount + ')';
|
||||
if (rainJoinButton.length == 0 || rainJoinButton.text().toLowerCase() == 'joined') {
|
||||
console.log('There is no joinable rain');
|
||||
setTitle(rainTitle);
|
||||
return false;
|
||||
}
|
||||
console.log('Rain available to join!');
|
||||
player.play();
|
||||
let drizzleTitle = '🌧️ ' + title;
|
||||
let exclaimTitle = '⛈️ ' + title;
|
||||
setTitle(drizzleTitle);
|
||||
blink();
|
||||
}
|
||||
|
||||
function blink() {
|
||||
let blinkInterval = Math.floor(RECHECK_TIMER / 4);
|
||||
setTimeout(() => { setTitle(exclaimTitle); }, blinkInterval);
|
||||
setTimeout(() => { setTitle(drizzleTitle); }, blinkInterval * 2);
|
||||
setTimeout(() => { setTitle(exclaimTitle); }, blinkInterval * 3);
|
||||
setBlinkOn();
|
||||
setTimeout(setBlinkOff, blinkInterval);
|
||||
setTimeout(setBlinkOn, blinkInterval * 2);
|
||||
setTimeout(setBlinkOff, blinkInterval * 3);
|
||||
}
|
||||
|
||||
function setBlinkOn() {
|
||||
setTitle('🌧️ ' + rainTitle);
|
||||
setFavicon('https://icons.iconarchive.com/icons/gartoon-team/gartoon-weather/256/weather-shower-icon.png');
|
||||
}
|
||||
|
||||
function setBlinkOff() {
|
||||
setTitle('⛈️ ' + rainTitle);
|
||||
setFavicon('/favicon.ico');
|
||||
}
|
||||
|
||||
function setTitle(newTitle) {
|
||||
document.title = newTitle;
|
||||
}
|
||||
|
||||
function setFavicon(url) {
|
||||
var link = document.querySelector("link[rel~='icon']") || document.createElement('link');
|
||||
link.rel = 'icon';
|
||||
link.type = 'image/x-icon';
|
||||
link.href = url;
|
||||
(document.head || document.getElementsByTagName("head")[0]).appendChild(link);
|
||||
}
|
||||
|
||||
function runRoutines() {
|
||||
checkRain();
|
||||
setTimeout(runRoutines, RECHECK_TIMER);
|
||||
|
Loading…
x
Reference in New Issue
Block a user