Created
March 16, 2022 22:24
-
-
Save michaelnagy/5b4f4e47c676509c5ab1ccafb9d2ce48 to your computer and use it in GitHub Desktop.
Blaze crash game script to notify when a N number of below 2x games happen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const entries = document.querySelector(".entries") | |
const allGames = entries.children | |
function getGoodNodeIndex() { | |
const allGamesArr = Array.from(allGames) | |
const goodPosition = allGamesArr.findIndex((item) => { | |
return item.className === 'good' | |
}) | |
return goodPosition | |
} | |
const observer = new MutationObserver((mutations, observer) => { | |
if(getGoodNodeIndex() >= 3) { | |
if (Notification.permission === "granted") { | |
new Notification("Hora de jogar Blaze"); | |
} | |
if (Notification.permission !== "denied") { | |
Notification.requestPermission((permission) => { | |
if (permission === "granted") { | |
new Notification("Hora de jogar Blaze") | |
} | |
}); | |
} | |
}}); | |
observer.observe(entries, { | |
childList: true, | |
subtree: true | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment