User:Habst/getKarmarush.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
const MEET = '5657';
const ws = new WebSocket(`wss://franklin-f56f3.firebaseio.com/.ws?${new URLSearchParams({v:5,ns:'franklin-f56f3'})}`);
let r = 1;
const send = p => ws.send(JSON.stringify({ t: "d", d: { r: r++, a: "q", b: { p: `/${MEET}/${p}`, h: "" } } }));
let msg = '';
ws.onmessage = ({ data }) => {
  msg += data;
  let d;
  try {
    const resp = JSON.parse(msg);
    d = resp.d ?? {};
    msg = '';
  } catch { return; }
  const dat = d?.b?.d ?? {};
  if (d.a === 'd') {
    switch (d.b?.p?.split('/')[1]) {
      case 'Schedule': {
        for (const evt in dat) {
          console.log(dat[evt].N, dat[evt].RN, new Date(dat[evt].T));
          send(`MeetEvents/${evt}`);
          break;
        }
        break;
      }
      case 'MeetEvents': {
        for (const aid in dat.ED) {
          const ath = dat.ED[aid];
          console.log(ath.A.N, ath.TN, ath.PR, ath.SB, ath.A.IAAF);
        }
        break;
      }
      case 'Meta': {
        console.log(dat);
        break;
      }
    }
  }
}
ws.onopen = () => send('Meta');