update
This commit is contained in:
parent
f9383a99c9
commit
3d316fab7d
2 changed files with 14 additions and 1 deletions
11
answer.js
11
answer.js
|
@ -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 [];
|
||||||
|
|
|
@ -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":
|
||||||
|
|
Loading…
Reference in a new issue