Auto quizzez AI bot 10ms delay [auto retry untill 100% awnser saver]

this bot saves all right question and rembers the Q&A for later Q&A's are now stored;so it does not have to learn the same quiz again

As of 2020-10-07. See the latest version.

// ==UserScript==
// @name         Auto quizzez AI bot 10ms delay [auto retry untill 100% awnser saver]
// @namespace    http://tampermonkey.net/
// @version      0.9
// @description  this bot saves all right question and rembers the Q&A for later Q&A's are now stored;so it does not have to learn the same quiz again
// @author       You
// @match        *://quizizz.com/*
// @grant        none
// ==/UserScript==
document.onkeypress=function(e){
    if(e.code=='Semicolon'){
        go=!go;
        console.log(go);
        win1.write('<span style="color:red">logging '+go+'</span>')
    }
}
var go;
var crtask
ag=true;
get=function(e,v=undefined){return v==undefined?localStorage.getItem(e):localStorage.setItem(e,v);};
function setStreak(){try{streak=document.getElementsByClassName('current-streak')[0].innerText*1;return streak}catch(err){}};
var streak,oldst,redeem,power,text,option,question,choose=[],t2,t3,qtext,atext
function testA(){
option.click();}
function chooseA(){
    crtask='setting guesanswer'
    win1.scrollBy(0,100)
    choose=document.getElementsByClassName('option-inner');
    question=document.getElementsByClassName('resizeable question-text-color');
    if(choose.length){
        option=choose[Math.floor(Math.random()*choose.length)]
}
try{qtext=question[0].innerText
atext=option.innerText}catch(err){};
}
function powerup(){
    power=document.getElementsByClassName('powerup-icon control-center-btn')
    if(power){
        for(let u=0;u<power.length;u++){
            power[u].click();
            console.log('click on power up');
        }
        setTimeout(function(){
            for(let i=0;i<document.getElementsByClassName('apply-powerup-button').length;i++){
                document.getElementsByClassName('apply-powerup-button')[i].click();
                console.log('activating power up');
                crtask='using powerup'
            }
        },200)
    };
}
function next(){
    if(document.getElementsByClassName('go-right-icon-wrapper').length>0){
        document.getElementsByClassName('go-right-icon-wrapper')[0].click();
        crtask='skipping'
    }
}
function checkst(){setStreak();if(oldst!=streak){crtask='setting streak'};if(streak>oldst){save(),console.log('save')};oldst=streak}
function findsave(){
chooseA();
var found=false;
for(let i=0;i<choose.length;i++){
choose[i].innerText==get(qtext)&&(atext=choose[i].inenrText,choose[i].click(),found=true,crtask='found answer')
}
return found
}
function save(){get(qtext,atext);console.log('saved',qtext,'with',atext),crtask='saving answer'}
function redeemQ(){
    crtask='trying redeem'
    redeem=document.getElementsByClassName('gradient-container');
    if(redeem.length){redeem[Math.floor(Math.random()*redeem.length)].click()};
}
function again(){
    if(document.getElementsByClassName('container incorrect-container').length>0){
        if(document.getElementsByClassName('container incorrect-container')[0].children.length>1){
            if(document.getElementsByClassName('container incorrect-container')[0].children[1].innerText*1){
                document.getElementsByClassName('primary-action-btn')[0].click();
                crtask='trying again'
                startwin();
            }
        }
    }
}
function skip(){
try{document.getElementsByClassName('right-navigator')[0].click();crtask='skipping'}catch(err){answer();}
}
window.win1=null;
function checkWin(myWindow=this.win1) {return !myWindow?false:myWindow.closed?false:true}
function startwin(){
    if(!checkWin(this.win1))(this.win1=open('','PROFILES',`width=256,height=305`),
                            setTimeout(function(){
    win1.resizeTo(305,'1000')
        win1.document.head.innerHTML=`
<style>
span {
color:white
}
body {
    background-color: rgb(54, 57, 63);
    }
img
   {
  border: 2px solid red;
  border-radius: 8px;
  border-style: solid;
  border-width: medium;
}
</style>
`
        win1.write=function(txt){win1.document.body.innerHTML+=txt}
    },500));
    else (in1=open('','PROFILES',`width=256,height=305`),win1.document.body.innerHTML='')
}
function answer(){
    crtask='answering questoin'
    !findsave()&&(testA(),setTimeout(checkst,5))
}
startwin();
startwin();
setInterval(skip,0);
var oldt='';
setInterval(e=>{
    chooseA();
    if(qtext!=oldt&&go&&get(qtext)!=null&&ag){
        redeemQ();
        powerup();
        answer();
    }
    else{
        redeemQ();
        powerup();
        answer();
    }
    oldt=qtext;
},10);
setInterval(again,500);
var rank,oldrank,oldtask
setInterval(function(){
    if(crtask!=oldtask)(win1.write('<span>'+crtask+'</span><br>'));;
    oldtask=crtask
    rank=document.getElementsByClassName('rank')[0].innerText.split('rd')[0].split('th')[0].split('nd')[0]*1;

    if(oldrank!=rank){
        if(rank>oldrank){
            console.log('when up ',rank-oldrank);
        }
        if(rank<oldrank){
            console.log('when down ',rank-oldrank);
        }
    }
},0)