Kahoot PIN Checker

Check pin of a kahoot game.

当前为 2019-11-09 提交的版本,查看 最新版本

// ==UserScript==
// @name         Kahoot PIN Checker
// @namespace    http://tampermonkey.net/
// @version      0.0.4
// @description  Check pin of a kahoot game.
// @author       theusaf
// @match        *://play.kahoot.it/*
// @grant        none
// ==/UserScript==

window.onload = ()=>{
  if(localStorage.doAutoRelogin == "true"){
      localStorage.doAutoRelogin = false;
      const waiter = setInterval(()=>{
          const a = document.querySelector("[data-functiontal-selector=launch-button]");
          if(a){
              a.click();
              clearInterval(waiter);
          }
      },500);
  }
};

window.Check = function(pin){
    return new Promise(function(res,rej){
        const x = new XMLHttpRequest();
        x.open("GET",`https://cors-anywhere.herokuapp.com/https://kahoot.it/reserve/session/${window.pinCheck}/?${Date.now()}`);
        x.send();
        x.onload = function(){
            res(x.response);
        };
    });
}

window.intervalCheck = setInterval(()=>{
    window.Check(window.pinCheck).then(o=>{
        if(o == "Not found"){
            localStorage.doAutoRelogin = true;
            document.write(`<script>window.location = "https://play.kahoot.it/v2/${window.location.search}"</script>`);
        }
    });
},1000*60*5);

window.otherInterval = setInterval(()=>{
    const pind = document.querySelector("[data-functional-selector=game-pin]");
    if(pind){
        window.pinCheck = pind.innerHTML;
    }
},100);