netacad script

skript na vyplnovani netacad linux testu

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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()
})();