Skip to content

Instantly share code, notes, and snippets.

@michaelnagy
Created March 16, 2022 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelnagy/5b4f4e47c676509c5ab1ccafb9d2ce48 to your computer and use it in GitHub Desktop.
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
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