1
1
Fork 0
CCNA_Autofill_Userscript/src/main.user.js
2024-05-23 19:08:18 +02:00

38 lines
No EOL
1.2 KiB
JavaScript

// ==UserScript==
// @name CCNA Autofill
// @namespace Violentmonkey Scripts
// @match *://assessment.netacad.net/*
// @match *://www.assessment.netacad.net/*
// @match *://www.google.com/*
// @match *://www.google.de/*
// @require https://git.euph.dev/SZUT-Dominik/CCNA_Autofill_Userscript/raw/branch/main/src/fetch.js
// @require https://git.euph.dev/SZUT-Dominik/CCNA_Autofill_Userscript/raw/branch/main/src/answer.js
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_xmlhttpRequest
// @version 1.0.0
// @author Dominik Säume
// ==/UserScript==
const URL_STORAGE_KEY = "itexamanswers.net URL";
/** @type {Array<Answer>} */
let answerData;
window.addEventListener("keydown", async (event) => {
switch(event.key){
case "p":
const oldAnswersURL = GM_getValue(URL_STORAGE_KEY);
const newAnswersURL = prompt("Please input the answer url (itexamanswers.net)", oldAnswersURL);
GM_setValue(URL_STORAGE_KEY, newAnswersURL);
answerData = await window.fetchAnswers(newAnswersURL);
break;
case "n":
document.getElementById("next").click();
break;
case "a":
window.answerQuestion(answerData);
break;
}
});