netacad script

skript na vyplnovani netacad linux testu

Verze ze dne 14. 04. 2019. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         netacad script
// @namespace    http://lkov.tk/
// @version      1.1
// @description  skript na vyplnovani netacad linux testu
// @author       @sirluky
// @include      https://content.netdevgroup.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
function r(){

fetch(`https://api.jsonbin.io/b/5ca52dba34241f2ab5e1ba79`).then(e => e.json()).then(unparseddata => {
const parsedData = unparseddata;
//parsedData.push(prompt("zadejte ziskany kod"))
/**
 * @param {*} n question number
 * return string with answer
 */

function start(){
document.querySelectorAll("#tour2 > .ndg-menu-btn").forEach( async function (e) {await setTimeout(()=>{},1000);e.click();})
  let phase = 0;
    runForAll()
  function runForAll(){
    setTimeout(e => {
      let question = getQuestion(phase)
      let answers = findAnswer(question, parsedData);
      answers.forEach(answer => {
        checkAnswer(phase, answer)
      })
      if (question) {
        phase++;
        setTimeout(e => {
          runForAll()
        }, 300);
      }
    }, 300)
  }

}
function getQuestion(n) {
  return document.querySelectorAll(".panel-body")[n].querySelector("div").innerText
}
function checkAnswer(n,text){
  let list = []
  document.querySelectorAll(".panel-body")[n].querySelectorAll(".answer_container div").forEach((e,index) => list.push([e.innerText,index]))
  list = list.filter(e => e[0] === text);
  // list = list.length > 0 ? true :false;
  console.log(list)
  if(list.length > 0){
    console.log(list[0][1])
    document.querySelectorAll(".panel-body")[n].querySelectorAll(".answer_container div")[list[0][1]].parentElement.parentElement.childNodes[1].checked = true
  } else {
    document.querySelectorAll(".panel-body")[n].style.background = "mistyrose"
  }
  return list;
}

//question to select
function findAnswer(toFind, myData) {
  let ans = myData.filter(e => e.question === toFind.slice(0, e.question.length));
  if(ans.length > 0){
  return ans[0].answers;
  } else{
    return []
  }
}
start()
// document.querySelectorAll(".panel-body")[n].querySelector("answer_container div")

/*

parsing from https://www.ccna7.com/linux-essentials/linux-essentials-chapter-2-exam/
*/



//quesetion
// document.querySelectorAll("ol>li")[0 /* question number */ ].querySelectorAll("h3")[1].innerText
//answers
// document.querySelectorAll("ol>li")[0 /* question number */ ].querySelectorAll("span")[0].innerText
})
} r()
})();