mirror of
https://github.com/nunocoracao/blowfish.git
synced 2025-01-23 06:55:43 -06:00
1 line
No EOL
832 B
JavaScript
1 line
No EOL
832 B
JavaScript
if(typeof auth!="undefined"){var viewsCollection=db.collection("views"),update_views,update_likes,likesCollection=db.collection("likes");function numberWithCommas(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}update_views=function(e,t){viewsCollection.doc(t).onSnapshot(t=>{var n=t.data();n&&(e.innerText=numberWithCommas(n.views))})},update_likes=function(e,t){likesCollection.doc(t).onSnapshot(t=>{var n=t.data();n&&(e.innerText=numberWithCommas(n.likes))})},auth.signInAnonymously().then(()=>{var e,t,n,s,o=document.querySelectorAll("span[id^='views_']");for(n in o)e=o[n],t=e.id?e.id.replaceAll("/","-"):e.id,t&&update_views(e,t);s=document.querySelectorAll("span[id^='likes_']");for(n in s)e=s[n],t=e.id?e.id.replaceAll("/","-"):e.id,t&&update_likes(e,t)}).catch(e=>{var t=e.code,n=e.message;console.error(t,n)})} |