Skip to content

Instantly share code, notes, and snippets.

@nfl0
Last active April 30, 2021 17:00
Show Gist options
  • Save nfl0/d36f90b4fbd2f5ffe16d28dbc267a828 to your computer and use it in GitHub Desktop.
Save nfl0/d36f90b4fbd2f5ffe16d28dbc267a828 to your computer and use it in GitHub Desktop.
ethglobal.tv chat name's annimation + poap notification
//set interval
var tid = setInterval(mycode, 5000);
var locs=["hi","MA"]; //3
var arr = ["nfl0💎","nfl0💎"];
var n;
function askForApproval() {
if (Notification.permission === "granted") {
createNotification('POAP', 'POAP');
} else {
Notification.requestPermission(permission => {
if (permission === 'granted') {
createNotification('POAP', 'POAP');
}
});
}
}
function createNotification(title, text) {
const noti = new Notification(title, {
body: text
});
}
arr = arr.map(function(value) {
return '..' + value;
})
//prev = document.getElementById("messages").innerText.match(/poap/ig);
var i = 0;
function mycode() {
// n=0;
n = document.getElementById("messages").innerText.match(/poap/ig);
console.log("POAP " + n.length + " times");
if (n.lenght != prev.lenght) {
askForApproval();
prev = n;
}
window.USER.name = arr[i];
window.USER.country = locs[i];
$(".flag").text(countryToEmoji(window.USER.country || "US"))
window.chat.updatePresence(true);
updateProfileInfo();
if (i == 1) {
i = 0;
} else {
++i;
}
str = 0;
n = 0;
}
function abortTimer() { // to be called when you want to stop the timer
clearInterval(tid);
}
//askForApproval();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment