MediaWiki:VisitorsIndicator.js: Difference between revisions

From VRChat Wiki
(Created page with "$( (function () { })() );")
 
No edit summary
Line 1: Line 1:
$(
$(
(function () {
  (function () {
    const element = document.querySelector("#mw-indicator-visitors-count");
})()
 
    async function refresh() {
      const visitors = (await fetch(`https://plausible.io/api/stats/wiki.vrchat.com/pages/?period=realtime&filters=[["is","event:page",["${location.pathname}"]]]`)
        .then((response) => response.json()))
        .results[0].visitors
 
      element.textContent = visitors;
    }
 
    refresh();
    setInterval(refresh, 1000)
  })()
);
);

Revision as of 23:52, 3 October 2024

$(
  (function () {
    const element = document.querySelector("#mw-indicator-visitors-count");

    async function refresh() {
      const visitors = (await fetch(`https://plausible.io/api/stats/wiki.vrchat.com/pages/?period=realtime&filters=[["is","event:page",["${location.pathname}"]]]`)
        .then((response) => response.json()))
        .results[0].visitors

      element.textContent = visitors;
    }

    refresh();
    setInterval(refresh, 1000)
  })()
);