1
1
Fork 0
This commit is contained in:
Dominik Säume 2024-05-23 17:38:36 +02:00
parent f9383a99c9
commit 3d316fab7d
Signed by: SZUT-Dominik
GPG key ID: 67D15BB250B41E7C
2 changed files with 14 additions and 1 deletions

View file

@ -1,3 +1,8 @@
/**
*
* @param {Array<Answer>} answerData
* @returns
*/
function answerQuestion(answerData){ function answerQuestion(answerData){
const question = document.querySelector(".question:not(.hidden)"); const question = document.querySelector(".question:not(.hidden)");
if (!question) { if (!question) {
@ -30,6 +35,12 @@ function answerQuestion(answerData){
} }
} }
/**
*
* @param {Array<Answer>} answerData
* @param {string} questionText
* @returns
*/
function findAnswers(answerData, questionText, answers) { function findAnswers(answerData, questionText, answers) {
if (answerData === null) { if (answerData === null) {
return []; return [];

View file

@ -10,11 +10,12 @@
// @grant GM_setValue // @grant GM_setValue
// @grant GM_getValue // @grant GM_getValue
// @grant GM_xmlhttpRequest // @grant GM_xmlhttpRequest
// @version 0.0.12 // @version 0.0.13
// @author Dominik Säume // @author Dominik Säume
// ==/UserScript== // ==/UserScript==
const URL_STORAGE_KEY = "itexamanswers.net URL"; const URL_STORAGE_KEY = "itexamanswers.net URL";
/** @type {Array<Answer>} */
let answerData; let answerData;
window.addEventListener("keydown", async (event) => { window.addEventListener("keydown", async (event) => {
@ -24,6 +25,7 @@ window.addEventListener("keydown", async (event) => {
const newAnswersURL = prompt("Please input the answer url (itexamanswers.net)", oldAnswersURL); const newAnswersURL = prompt("Please input the answer url (itexamanswers.net)", oldAnswersURL);
GM_setValue(URL_STORAGE_KEY, newAnswersURL); GM_setValue(URL_STORAGE_KEY, newAnswersURL);
answerData = await window.fetchAnswers(newAnswersURL); answerData = await window.fetchAnswers(newAnswersURL);
console.log(answerData);
break; break;
case "n": case "n":