diff --git a/frame.js b/frame.js
index 5b36b91..fea8228 100644
--- a/frame.js
+++ b/frame.js
@@ -21,7 +21,7 @@
// ==UserScript==
// @name Moodle/Elearning/KMOOC test help
-// @version 1.6.3.1
+// @version 1.6.3.3
// @description Online Moodle/Elearning/KMOOC test help
// @author MrFry
// @match https://elearning.uni-obuda.hu/main/*
diff --git a/main.js b/main.js
index 67480d3..21e7e35 100644
--- a/main.js
+++ b/main.js
@@ -903,7 +903,7 @@ function Version16 () {
// : }}}
-var GetFileData = () => {
+function GetFileData () {
return getResourceText('data')
}
diff --git a/stable.js b/stable.js
index 04e398b..1372c51 100644
--- a/stable.js
+++ b/stable.js
@@ -21,7 +21,7 @@
// ==UserScript==
// @name Moodle/Elearning/KMOOC test help
-// @version 1.6.3.2
+// @version 1.6.3.3
// @description Online Moodle/Elearning/KMOOC test help
// @author MrFry
// @match https://elearning.uni-obuda.hu/main/*
@@ -41,13 +41,20 @@
// ==/UserScript==
(function() {
- /* TODO
- * remove stuff like "b. answer", "c. answer" ....
- * */
+ // GM functions, only to disable ESLINT errors
+ /* eslint-disable */
+ const a = Main
+ function getVal (name) { return GM_getValue(name) }
+ function setVal (name, val) { return GM_setValue(name, val) }
+ function openInTab (address, options) { GM_openInTab(address, options) }
+ function getResourceText (name) { return GM_getResourceText(name) }
+ function xmlhttpRequest (opts) { GM_xmlhttpRequest(opts) }
+ function info () { return GM_info }
+ /* eslint-enable */
var data // all data, which is in the resource txt
var addEventListener // add event listener function
- const lastChangeLog = 'Néhány szerkezeti átalakítás, és bugfix. Ha valami elromlott akkor pls report, thanx'
+ const lastChangeLog = 'Félév szerinti csoportosítás menüben'
const serverAdress = 'https://qmining.frylabs.net/'
// forcing pages for testing. unless you test, do not set these to true!
@@ -221,18 +228,53 @@
this.Name = n
this.Questions = []
+ this.active = false
+ }
+
+ setIndex (i) {
+ this.index = i
+ }
+
+ getIndex () {
+ return this.index || -1
}
get length () {
return this.Questions.length
}
+ markActive () {
+ this.active = true
+ }
+
+ getIfActive () {
+ return this.active
+ }
+
AddQuestion (q) {
assert(q)
this.Questions.push(q)
}
+ getSubjNameWithoutYear () {
+ let t = this.Name.split(' - ')
+ if (t[0].match(/^[0-9]{4}\/[0-9]{2}\/[0-9]{1}$/i)) {
+ return t[1] || ''
+ } else {
+ return ''
+ }
+ }
+
+ getYear () {
+ let t = this.Name.split(' - ')[0]
+ if (t.match(/^[0-9]{4}\/[0-9]{2}\/[0-9]{1}$/i)) {
+ return t
+ } else {
+ return ''
+ }
+ }
+
Search (q, img) {
assert(q)
@@ -279,7 +321,7 @@
get activeIndexes () {
var r = []
for (var i = 0; i < this.length; i++) {
- if (GM_getValue('Is' + i + 'Active')) {
+ if (getVal('Is' + i + 'Active')) {
r.push(i)
}
}
@@ -287,11 +329,11 @@
}
GetIfActive (ind) {
- return GM_getValue('Is' + ind + 'Active')
+ return getVal('Is' + ind + 'Active')
}
ChangeActive (i, value) {
- GM_setValue('Is' + i + 'Active', !!value)
+ setVal('Is' + i + 'Active', !!value)
}
AddQuestion (subj, q) {
@@ -532,7 +574,7 @@
var items = results[i].getElementsByTagName('label')
var r = []
for (var j = 0; j < items.length; j++) {
- function TryGetCorrect (j) {
+ const TryGetCorrect = (j) => {
var cn = items[j].parentNode.className
if (cn.includes('correct')) { return cn.includes('correct') && !cn.includes('incorrect') }
}
@@ -561,7 +603,9 @@
if (logElementGetting) { Log('Getting right answer if correct not shown') }
var results = this.GetFormResult() // getting results element
var n = results[i].getElementsByTagName('i')[0].parentNode
- if (n.className.includes('correct') && !n.className.includes('incorrect')) { return results[i].getElementsByTagName('i')[0].parentNode.innerText } else { return '' }
+ if (n.className.includes('correct') && !n.className.includes('incorrect')) {
+ return results[i].getElementsByTagName('i')[0].parentNode.innerText
+ }
}
GetFormCFOfResult (result) {
@@ -581,6 +625,15 @@
return this.GetFormCFOfResult(results[i]).getElementsByTagName('img')
}
+ GetOnlyImageQuestionResult (i) {
+ console.log('############################################################')
+ console.log(i)
+ const results = this.GetFormResult() // getting results element
+ const n = results[i]
+ console.log(n)
+ console.log('############################################################')
+ }
+
// gets the question from the result page
// i is the index of the question
GetQuestionFromResult (i) {
@@ -629,6 +682,11 @@
if (RPM.GetDropboxes(i).length > 0) { return RPM.GetCurrentAnswer(i) }
})
+ // image and text only question
+ fun.push(function TryGet5 (i) {
+ return RPM.GetOnlyImageQuestionResult(i)
+ })
+
// if the correct answers are not shown, and the selected answer
// is correct
fun.push(function TryGet2 (i) {
@@ -658,7 +716,10 @@
var j = 0
var currAnswer
while (j < fun.length && SUtils.EmptyOrWhiteSpace(currAnswer)) {
- currAnswer = fun[j](i)
+ try {
+ currAnswer = fun[j](i)
+ } catch (e) {
+ }
j++
}
@@ -717,18 +778,17 @@
var MPM = new MiscPageModell()
// : }}}
-
- Main()
// : Main function {{{
+ Main()
function Main () {
'use strict'
console.time('main')
Init(function (count, subjCount) {
- var url = location.href
+ var url = location.href // eslint-disable-line
- let skipLoad = GM_getValue('skipLoad')
+ let skipLoad = getVal('skipLoad')
if (count === -2 && subjCount === -2 && skipLoad) {
if (url.includes('/quiz/') && url.includes('attempt.php')) {
ShowMessage({
@@ -751,7 +811,7 @@
m: 'Fatál error. Check console (f12). Kattints az üzenetre az összes kérdés/válaszért manuális kereséshez!',
isSimple: true
}, undefined, function () {
- GM_openInTab(serverAdress + 'lred', {
+ openInTab(serverAdress + 'lred', {
active: true
})
})
@@ -778,14 +838,14 @@
// : Loading {{{
function Init (cwith) {
- if (false) {
- GM_setValue('version16', undefined)
- GM_setValue('version15', undefined)
- GM_setValue('firstRun', undefined) // GM_getValue("lastVerson") == undefined => firstrun
- GM_setValue('showQuestions', undefined)
- GM_setValue('showSplash', undefined)
+ if (false) { // eslint-disable-line
+ setVal('version16', undefined)
+ setVal('version15', undefined)
+ setVal('firstRun', undefined)
+ setVal('showQuestions', undefined)
+ setVal('showSplash', undefined)
}
- var url = location.href // window location
+ var url = location.href // eslint-disable-line
var count = -1 // loaded question count. stays -1 if the load failed.
// --------------------------------------------------------------------------------------
// event listener fuckery
@@ -814,82 +874,64 @@
function VersionActions () {
// FOR TESTING ONLY
- // GM_setValue("version15", true);
- // GM_setValue("firstRun", true);
- // GM_setValue("version16", true);
- // GM_setValue("version161", true);
+ // setVal("version15", true);
+ // setVal("firstRun", true);
+ // setVal("version16", true);
// throw "asd";
- let r = FreshStart()
- if (r !== true) { GM_setValue('version161', false) }
+ FreshStart()
Version15()
Version16()
- Version161()
}
// : Version action functions {{{
function FreshStart () {
- var firstRun = GM_getValue('firstRun') // if the current run is the frst
+ var firstRun = getVal('firstRun') // if the current run is the frst
if (firstRun === undefined || firstRun === true) {
- GM_setValue('firstRun', false)
+ setVal('firstRun', false)
ShowHelp() // showing help
return true
}
}
function Version15 () {
- var version15 = GM_getValue('version15') // if the current run is the frst
+ var version15 = getVal('version15') // if the current run is the frst
if (version15 === undefined || version15 === true) {
- GM_setValue('useNetDB', '1')
- GM_setValue('version15', false)
+ setVal('useNetDB', '1')
+ setVal('version15', false)
document.write(
'
Moodle teszt userscript:1.5.0 verzió: a script mostantól XMLHTTP kéréseket küld szerver fele! Erre a userscript futtató kiegészitőd is figyelmeztetni fog! Ha ez történik, a script rendes működése érdekében engedélyezd (Always allow domain)! Ha nem akarod, hogy ez történjen, akkor ne engedélyezd, vagy a menüben válaszd ki a "helyi fájl használata" opciót!
Elküldött adatok: minden teszt után a kérdés-válasz páros. Fogadott adatok: Az összes eddig ismert kérdés. Érdemes help-et elolvasni!!!
Ez az ablak frissités után eltűnik. Ha nem, akkor a visza gombbal próbálkozz.
'
)
document.close()
- throw 'something, so this stuff stops'
+ throw 'something, so this stuff stops' // eslint-disable-line
}
}
function Version16 () {
- var version16 = GM_getValue('version16') // if the current run is the frst
- if (version16 == undefined || version16 == true) // if its undefined, or true
- {
+ var version16 = getVal('version16') // if the current run is the frst
+ if (version16 === undefined || version16 === true) {
var i = 0
- while (GM_getValue('Is' + i + 'Active') != undefined) {
- GM_setValue('Is' + i + 'Active', false)
+ while (getVal('Is' + i + 'Active') !== undefined) {
+ setVal('Is' + i + 'Active', false)
i++
}
- GM_setValue('version16', false)
- }
- }
-
- function Version161 () {
- var version161 = GM_getValue('version161') // if the current run is the frst
- if (version161 == undefined || version161 == true) // if its undefined, or true
- {
- GM_setValue('useNetDB', '1')
- GM_setValue('version161', false)
- document.write(
- 'Moodle teszt userscript:1.6.1.0 verzió: Új domain név: qmining.tk. Ha frissíted az oldalt, akkor tampremonkey rá fog kérdezni, hpgy engedélyezed-e a kérdések külését erre az új domain-re. A rendes működés érdekében kattints a "Allow always domain"-gombra
'
- )
- document.close()
- throw 'something, so this stuff stops'
+ setVal('version16', false)
}
}
// : }}}
- var GetFileData = () => {
- return GM_getResourceText('data')
+ function GetFileData () {
+ return getResourceText('data')
}
function ReadFile (cwith) {
var resource = ''
try {
resource = GetFileData() // getting data from txt
- if (resource == undefined) {
+ if (resource === undefined) {
ShowMessage({
m: 'Nem lehetett beolvasni a fájlt :c Ellenőrizd az elérési utat, vagy a fájl jogosultságokat',
isSimple: true
@@ -897,9 +939,7 @@
return
}
if (SUtils.EmptyOrWhiteSpace(resource)) {
- throw {
- message: 'data file empty'
- }
+ throw 'data file empty' // eslint-disable-line
}
} catch (e) {
Exception(e, 'script error at reading file:')
@@ -910,7 +950,7 @@
function ReadNetDB (cwith, useNetDB) {
function NewXMLHttpRequest () {
const url = serverAdress + 'data.json'
- GM_xmlhttpRequest({
+ xmlhttpRequest({
method: 'GET',
synchronous: true,
url: url,
@@ -962,7 +1002,7 @@
let currData = d[i].substring(1).trim()
- if (currIdentifier == '+') {
+ if (currIdentifier === '+') {
if (currQuestion.IsComplete()) { r.AddQuestion(currSubj, currQuestion) }
currQuestion = new Question()
currSubj = currData
@@ -970,7 +1010,7 @@
continue
}
- if (currIdentifier == '?') {
+ if (currIdentifier === '?') {
if (currQuestion.IsComplete()) {
r.AddQuestion(currSubj, currQuestion)
currQuestion = new Question()
@@ -982,9 +1022,11 @@
continue
}
- if (currIdentifier == '!') {
+ if (currIdentifier === '!') {
// if dont have question continue
- if (!currQuestion.HasQuestion()) { throw 'No question! (A)' }
+ if (!currQuestion.HasQuestion()) {
+ throw 'No question! (A)' // eslint-disable-line
+ }
// dont allow overwriting
// ?!!!!
if (!currQuestion.HasAnswer()) {
@@ -997,10 +1039,14 @@
continue
}
- if (currIdentifier == '>') {
+ if (currIdentifier === '>') {
// if dont have question or answer continue
- if (!currQuestion.HasQuestion()) { throw 'No question! (I)' }
- if (!currQuestion.HasAnswer()) { throw 'No asnwer! (I)' }
+ if (!currQuestion.HasQuestion()) {
+ throw 'No question! (I)' // eslint-disable-line
+ }
+ if (!currQuestion.HasAnswer()) {
+ throw 'No asnwer! (I)' // eslint-disable-line
+ }
// dont allow overwriting
// ?!>>>
if (!currQuestion.HasImage()) {
@@ -1022,15 +1068,15 @@
}
function Load (cwith) {
- var useNetDB = GM_getValue('useNetDB')
- let skipLoad = GM_getValue('skipLoad')
+ var useNetDB = getVal('useNetDB')
+ let skipLoad = getVal('skipLoad')
if (skipLoad) {
cwith(-2, -2)
return -1
}
- if (useNetDB != undefined && useNetDB == 1) { return ReadNetDB(cwith, useNetDB) } else { return ReadFile(cwith) }
+ if (useNetDB !== undefined && useNetDB === 1) { return ReadNetDB(cwith, useNetDB) } else { return ReadFile(cwith) }
}
function LoadMOTD (resource) {
@@ -1080,9 +1126,11 @@
LoadMOTD(d)
LoadVersion(d)
- for (var i = 0; i < d.Subjects.length; i++) {
+ for (let i = 0; i < d.Subjects.length; i++) {
let s = new Subject(d.Subjects[i].Name)
- if (GM_getValue('Is' + i + 'Active')) {
+ s.setIndex(i)
+ if (getVal('Is' + i + 'Active')) {
+ s.markActive()
var j = 0
for (j = 0; j < d.Subjects[i].Questions.length; j++) {
var currQ = d.Subjects[i].Questions[j]
@@ -1100,8 +1148,8 @@
data = r
count = allCount + 1 // couse starting with -1 to show errors
- var i = 0
- while (i < data.length && !GM_getValue('Is' + i + 'Active')) {
+ let i = 0
+ while (i < data.length && !getVal('Is' + i + 'Active')) {
i++
}
} catch (e) {
@@ -1124,30 +1172,26 @@
// : UI handling {{{
function HandleUI (url, count, subjCount) {
var newVersion = false // if the script is newer than last start
- var loaded = count != -1 // if script could load stuff
+ var loaded = count !== -1 // if script could load stuff
- try // try, cus im suspicious
- {
- newVersion = GM_info.script.version !== GM_getValue('lastVerson')
+ try {
+ newVersion = info().script.version !== getVal('lastVerson')
} catch (e) {
Log('Some weird error trying to set new verison')
}
var greetMsg = '' // message to show at the end
var timeout = null // the timeout. if null, it wont be hidden
// no new version, nothing loaded
- if (!newVersion && !loaded) // --------------------------------------------------------------------------------------------------------------
- {
- greetMsg =
- 'Hiba a @resource tagnál, vagy a fileval van gond! (Lehet át lett helyezve, vagy üres, vagy nincs tárgy kiválasztva) Vagy válaszd a netes adatok használatát menüben. Ellenőrizd az elérési utat, vagy hogy a Tampermonkey bővítmény eléri-e a fájlokat. Ha netes forrást használsz, akkor nem elérhető a szerver! Segítségért kattints!'
+ if (!newVersion && !loaded) { // --------------------------------------------------------------------------------------------------------------
+ greetMsg = 'Hiba a @resource tagnál, vagy a fileval van gond! (Lehet át lett helyezve, vagy üres, vagy nincs tárgy kiválasztva) Vagy válaszd a netes adatok használatát menüben. Ellenőrizd az elérési utat, vagy hogy a Tampermonkey bővítmény eléri-e a fájlokat. Ha netes forrást használsz, akkor nem elérhető a szerver! Segítségért kattints!'
}
- var showSplash = (GM_getValue('showSplash') == undefined) || GM_getValue('showSplash') // getting value, if splash screen should be shown. Its true, if its undefined, or true
+ var showSplash = (getVal('showSplash') === undefined) || getVal('showSplash') // getting value, if splash screen should be shown. Its true, if its undefined, or true
// no new version, everything loaded, and show splash is enabled. otherwise something happened, so showing it
- if (!newVersion && loaded && showSplash) // ------------------------------------------------------------------------------------------------
- {
+ if (!newVersion && loaded && showSplash) { // ------------------------------------------------------------------------------------------------
timeout = 5
- greetMsg = 'Moodle/Elearning/KMOOC segéd v. ' + GM_info.script.version + '. '
+ greetMsg = 'Moodle/Elearning/KMOOC segéd v. ' + info().script.version + '. '
- if (lastestVersion != undefined && GM_info.script.version != lastestVersion) {
+ if (lastestVersion !== undefined && info().script.version !== lastestVersion) {
greetMsg += 'Új verzió elérhető: ' + lastestVersion + '\n'
timeout = undefined
}
@@ -1159,7 +1203,7 @@
toAdd.push(data.Subjects[i].Name + ' (' + data.Subjects[i].length + ')')
}
}
- if (toAdd.length != 0) {
+ if (toAdd.length !== 0) {
greetMsg += '\nAktív tárgyak: ' + toAdd.join(', ') + '.'
} else {
AlertOnNoQuestion()
@@ -1171,31 +1215,25 @@
}
}
// new version, nothing loaded
- if (newVersion && !loaded) // --------------------------------------------------------------------------------------------------------------
- {
- greetMsg = 'Moodle/Elearning/KMOOC segéd v. ' + GM_info.script.version +
- '. Új verzió!\n Írd át a @resouce tagnál az elírési utat! Kivéve ha üres a file, akkor töltsd fel :) Nincs kérdés betöltve! Segítséghez kattints. Changelog:\n' +
- lastChangeLog // showing changelog too
+ if (newVersion && !loaded) { // --------------------------------------------------------------------------------------------------------------
+ greetMsg = 'Moodle/Elearning/KMOOC segéd v. ' + info().script.version + '. Új verzió!\n Írd át a @resouce tagnál az elírési utat! Kivéve ha üres a file, akkor töltsd fel :) Nincs kérdés betöltve! Segítséghez kattints. Changelog:\n' + lastChangeLog // showing changelog too
}
// new version, everything loaded -> set lastVerson to current
- if (newVersion && loaded) // --------------------------------------------------------------------------------------------------------------
- {
- greetMsg = 'Moodle/Elearning/KMOOC segéd v. ' + GM_info.script.version + '. ' + count +
- ' kérdés és ' + subjCount + ' tárgy betöltve. Verzió frissítve ' + GM_info.script.version +
- '-re. Changelog:\n' + lastChangeLog
- GM_setValue('lastVerson', GM_info.script.version) // setting lastVersion
+ if (newVersion && loaded) { // --------------------------------------------------------------------------------------------------------------
+ greetMsg = 'Moodle/Elearning/KMOOC segéd v. ' + info().script.version + '. ' + count + ' kérdés és ' + subjCount + ' tárgy betöltve. Verzió frissítve ' + info().script.version + '-re. Changelog:\n' + lastChangeLog
+ setVal('lastVerson', info().script.version) // setting lastVersion
}
if (!SUtils.EmptyOrWhiteSpace(motd)) {
- var prevmotd = GM_getValue('motd')
- if (prevmotd != motd) {
+ var prevmotd = getVal('motd')
+ if (prevmotd !== motd) {
greetMsg += '\nMOTD:\n' + motd
timeout = null
- GM_setValue('motdcount', motdShowCount)
- GM_setValue('motd', motd)
+ setVal('motdcount', motdShowCount)
+ setVal('motd', motd)
} else {
- var motdcount = GM_getValue('motdcount')
- if (motdcount == undefined) {
- GM_setValue('motdcount', motdShowCount)
+ var motdcount = getVal('motdcount')
+ if (motdcount === undefined) {
+ setVal('motdcount', motdShowCount)
motdcount = motdShowCount
}
@@ -1203,7 +1241,7 @@
if (motdcount > 0) {
greetMsg += '\nMOTD:\n' + motd
timeout = null
- GM_setValue('motdcount', motdcount)
+ setVal('motdcount', motdcount)
}
}
}
@@ -1220,16 +1258,14 @@
function HandleQuiz () {
var q = QPM.GetQuestionFromTest()
var questions = q.q
- var allQuestions = q.allQ
var imgNodes = q.imgnodes
// ------------------------------------------------------------------------------------------------------
var answers = []
- for (var j = 0; j < questions.length; j++) // going thru all answers
- {
+ for (var j = 0; j < questions.length; j++) {
var question = SUtils.RemoveUnnecesarySpaces(questions[j]) // simplifying question
var result = data.Search(question, SimplifyImages(imgNodes))
var r = PrepareAnswers(result, j)
- if (r != undefined) { answers.push(r) }
+ if (r !== undefined) { answers.push(r) }
HighLightAnswer(result, j) // highlights the answer for the current result
}
ShowAnswers(answers)
@@ -1238,19 +1274,15 @@
function PrepareAnswers (result, j) {
assert(result)
- if (result.length > 0) // if there are more than zero results
- {
+ if (result.length > 0) {
var allMessages = [] // preparing all messages
- for (var k = 0; k < result.length; k++) // going throuh all results
- {
+ for (var k = 0; k < result.length; k++) {
var msg = '' // the current message
- if ((GM_getValue('showQuestions') == undefined) || GM_getValue('showQuestions')) // if the question should be shown
- {
+ if ((getVal('showQuestions') === undefined) || getVal('showQuestions')) {
msg += result[k].q.Q + '\n' // adding the question if yes
}
msg += result[k].q.A.replace(/, /g, '\n') // adding answer
- if (result[k].q.HasImage()) // and adding image, if it exists
- {
+ if (result[k].q.HasImage()) {
msg += '\n' + result[k].q.I // if it has image part, adding that too
}
allMessages.push({
@@ -1272,7 +1304,7 @@
m: 'Nincs találat :( Kattints az üzenetre az összes kérdés/válaszért manuális kereséshez! Előfordulhat, hogy a tárgyat nem válsztottad ki a menüben.',
isSimple: true
}, undefined, function () {
- GM_openInTab(serverAdress + 'lred', {
+ openInTab(serverAdress + 'lred', {
active: true
})
})
@@ -1284,7 +1316,6 @@
// : Quiz saving {{{
function HandleResults (url) {
- var allResults = new QuestionDB()
var d = SaveQuiz(GetQuiz(), data) // saves the quiz questions and answers
if (d) { ShowSaveQuizDialog(d.addedQ, d.allQ, d.allOutput, d.output, d.sendSuccess, d.sentData) }
@@ -1292,17 +1323,14 @@
function ShowSaveQuizDialog (addedQ, allQ, allOutput, output, sendSuccess, sentData) {
var msg = ''
- if (addedQ > 0) // if there are more than 0 new question
- {
- msg = 'Klikk ide a nyers adatokhoz. ' + addedQ +
- ' új kérdés!'
+ if (addedQ > 0) {
+ msg = 'Klikk ide a nyers adatokhoz. ' + addedQ + ' új kérdés!'
- var useNetDB = GM_getValue('useNetDB')
- if (useNetDB != undefined && useNetDB == 1) {
+ var useNetDB = getVal('useNetDB')
+ if (useNetDB !== undefined && useNetDB === 1) {
if (!sendSuccess) { msg += ' Nem sikerült kérdéseket elküldeni szervernek. Ha gondolod utánanézhetsz.' } else { msg += 'Az új kérdések elküldve.' }
} else { msg += 'Ne felejtsd el bemásolni a fő txt-be!' }
- } else // if there is 0 or less new question
- {
+ } else {
msg = 'A kérdőívben nincsen új kérdés. Ha mégis le akarod menteni klikk ide.'
if (!data) { msg += ' Lehet azért, mert nincs kérdés betöltve.' }
}
@@ -1311,13 +1339,11 @@
m: msg,
isSimple: true
}, null, function () {
- var towrite = '' + sentData.subj + '
TXT-ben nem szereplő kérdések: ' + addedQ + '/' +
- allQ + '
' +
- output.replace(/\n/g, '
') + '
Összes kérdés/válasz:
' + allOutput.replace(
+ var towrite = '' + sentData.subj + '
TXT-ben nem szereplő kérdések: ' + addedQ + '/' + allQ + '
' + output.replace(/\n/g, '
') + '
Összes kérdés/válasz:
' + allOutput.replace(
/\n/g, '
')
- var useNetDB = GM_getValue('useNetDB')
- if (useNetDB != undefined && useNetDB == 1) {
+ var useNetDB = getVal('useNetDB')
+ if (useNetDB !== undefined && useNetDB === 1) {
try {
towrite += 'Elküldött adatok: ' + JSON.stringify(sentData)
} catch (e) {
@@ -1337,7 +1363,7 @@
if (item.match > minResultMatchPercent) { count++ }
})
- return count == 0 ? -1 : count
+ return count === 0 ? -1 : count
}
// this should get the image url from a result page
@@ -1348,8 +1374,7 @@
var imgElements = RPM.GetResultImage(i) // trying to get image
var imgURL = [] // image urls
for (var j = 0; j < imgElements.length; j++) {
- if (!imgElements[j].src.includes('brokenfile')) // idk why brokenfile is in some urls, which are broken, so why tf are they there damn moodle
- {
+ if (!imgElements[j].src.includes('brokenfile')) {
var filePart = imgElements[j].src.split('/') // splits the link by "/"
filePart = filePart[filePart.length - 1] // the last one is the image name
imgURL.push(decodeURI(SUtils.ShortenString(filePart, 30)))
@@ -1367,8 +1392,8 @@
// saves the current quiz. questionData contains the active subjects questions
function SaveQuiz (quiz, questionData) {
try {
- if (quiz.length == 0) {
- throw {
+ if (quiz.length === 0) {
+ throw { // eslint-disable-line
message: 'quiz length is zero!',
stack: 'no stack.'
}
@@ -1378,8 +1403,7 @@
var allQ = 0
var addedQ = 0
var newQuestions = []
- for (var i = 0; i < quiz.length; i++) // going though quiz
- {
+ for (var i = 0; i < quiz.length; i++) {
// searching for same questions in questionData
var toAdd = '' // this will be added to some variable depending on if its already in the database
toAdd += '?' + SUtils.RemoveUnnecesarySpaces(quiz[i].Q) + '\n' // adding quiz question
@@ -1387,8 +1411,7 @@
if (quiz[i].HasImage()) {
toAdd += '>' + SUtils.RemoveUnnecesarySpaces(quiz[i].I) + '\n' // adding quiz image if there is any
}
- if (SearchSameQuestion(questionData, quiz, i) == -1) // if there is no such item in the database (w/ same q and a)
- {
+ if (SearchSameQuestion(questionData, quiz, i) === -1) {
output += toAdd // adding to output
newQuestions.push(quiz[i])
addedQ++
@@ -1405,11 +1428,11 @@
sentData.subj = 'NOSUBJ'
Log('unable to get subject name :c')
}
- var useNetDB = GM_getValue('useNetDB')
- if (useNetDB != undefined && useNetDB == 1) {
+ var useNetDB = getVal('useNetDB')
+ if (useNetDB !== undefined && useNetDB === 1) {
sentData.allData = quiz
sentData.data = newQuestions
- sentData.version = GM_info.script.version
+ sentData.version = info().script.version
SendXHRMessage('datatoadd=' + JSON.stringify(sentData))
sendSuccess = true
}
@@ -1434,26 +1457,24 @@
try {
var quiz = [] // final quiz stuff
var results = RPM.GetFormResult() // getting results element
- for (var i = 0; i < results.length - 2; i++) // going through results, except last two, idk why, dont remember, go check it man
- {
+ for (var i = 0; i < results.length - 2; i++) {
var question = {} // the current question
// QUESTION --------------------------------------------------------------------------------------------------------------------
var q = RPM.GetQuestionFromResult(i)
- if (q != undefined) { question.q = SUtils.SimplifyQuery(q) }
+ if (q !== undefined) { question.q = SUtils.SimplifyQuery(q) }
// RIGHTANSWER ---------------------------------------------------------------------------------------------------------------------
var a = RPM.GetRightAnswerFromResultv2(i)
- if (a == undefined) { a = RPM.GetRightAnswerFromResult(i) }
- if (a != undefined) { question.a = SUtils.SimplifyQuery(a) }
+ if (a === undefined) { a = RPM.GetRightAnswerFromResult(i) }
+ if (a !== undefined) { question.a = SUtils.SimplifyQuery(a) }
// IMG ---------------------------------------------------------------------------------------------------------------------
var img = GetImageFormResult(i)
question.i = img
- if (q != undefined) { q = SUtils.ReplaceCharsWithSpace(q, '\n') }
- if (a != undefined) { a = SUtils.ReplaceCharsWithSpace(a, '\n') }
+ if (q !== undefined) { q = SUtils.ReplaceCharsWithSpace(q, '\n') }
+ if (a !== undefined) { a = SUtils.ReplaceCharsWithSpace(a, '\n') }
- if (question.a != undefined) // adding only if has question
- {
+ if (question.a !== undefined) {
quiz.push(new Question(question.q, question.a, question.i)) // adding current question to quiz
} else {
Log('error getting queston, no correct answer given, or its incorrect')
@@ -1472,10 +1493,8 @@
function SimplifyImages (imgs) {
var questionImages = [] // the array for the image names in question
- for (var i = 0; i < imgs.length; i++) // going through all image
- {
- if (!imgs[i].src.includes('brokenfile')) // if its includes borken file its broken. Its another moodle crap. So i just wont check those
- {
+ for (var i = 0; i < imgs.length; i++) {
+ if (!imgs[i].src.includes('brokenfile')) {
var filePart = imgs[i].src.split('/') // splits the link by "/"
filePart = filePart[filePart.length - 1] // the last one is the image name
questionImages.push(decodeURI(SUtils.RemoveUnnecesarySpaces(SUtils.ShortenString(filePart, 30)))) // decodes uri codes, and removes exess spaces, and shortening it
@@ -1486,10 +1505,8 @@
// adds image names to image nodes
function AddImageNamesToImages (imgs) {
- for (var i = 0; i < imgs.length; i++) // going through all image
- {
- if (!imgs[i].src.includes('brokenfile')) // if its includes borken file its broken. Its another moodle crap. So i just wont check those
- {
+ for (var i = 0; i < imgs.length; i++) {
+ if (!imgs[i].src.includes('brokenfile')) {
var filePart = imgs[i].src.split('/') // splits the link by "/"
filePart = filePart[filePart.length - 1] // the last one is the image name
var appedtTo = imgs[i].parentNode // it will be appended here
@@ -1505,13 +1522,11 @@
// this function adds basic hotkeys for video controll.
function AddVideoHotkeys (url) {
var seekTime = 20
- document.addEventListener('keydown', function (e) // keydown event listener
- {
+ document.addEventListener('keydown', function (e) {
try {
var video = MPM.GetVideo()
var keyCode = e.keyCode // getting keycode
- if (keyCode == 32) // if the keycode is 32 (space)
- {
+ if (keyCode === 32) { // if the keycode is 32 (space)
e.preventDefault() // preventing default action (space scrolles down)
if (video.paused && video.buffered.length > 0) {
video.play()
@@ -1519,12 +1534,10 @@
video.pause()
}
}
- if (keyCode == 39) // rigth : 39
- {
+ if (keyCode === 39) { // rigth : 39
video.currentTime += seekTime
}
- if (keyCode == 37) // left : 37
- {
+ if (keyCode === 37) { // left : 37
video.currentTime -= seekTime
}
} catch (err) {
@@ -1538,20 +1551,6 @@
node.style.margin = '5px 5px 5px 5px' // fancy margin
}
- // simple sort.
- function SortByPercent (results) {
- for (var i = 0; i < results.length; i++) {
- for (var j = results.length - 1; j > i; j--) {
- if (results[i].p < results[j].p) {
- var temp = results[i]
- results[i] = results[j]
- results[j] = temp
- }
- }
- }
- return results
- }
-
// removes stuff like " a. q1" -> "q1"
function RemoveLetterMarking (inp) {
let dotIndex = inp.indexOf('.')
@@ -1564,15 +1563,12 @@
// highlights the possible solutions to the current question
function HighLightAnswer (results, currQuestionNumber) {
try {
- if (results.length > 0) // if there are items in the result
- {
+ if (results.length > 0) {
var answers = RPM.GetAllAnswer(currQuestionNumber) // getting all answers
var toColor = [] // the numberth in the array will be colored, and .length items will be colored
var type = '' // type of the question. radio or ticbox or whatitscalled
- for (var i = 0; i < answers.length; i++) // going thtough answers
- {
- if (answers[i].tagName && answers[i].tagName.toLowerCase() == 'div') // if its not null and is "div"
- {
+ for (let i = 0; i < answers.length; i++) { // going thtough answers
+ if (answers[i].tagName && answers[i].tagName.toLowerCase() === 'div') { // if its not null and is "div"
var correct = results[0].q.A.toLowerCase() // getting current correct answer from data
var answer = answers[i].innerText.replace(/\n/g, '').toLowerCase() // getting current answer
@@ -1581,24 +1577,21 @@
if (SUtils.EmptyOrWhiteSpace(correct) || SUtils.EmptyOrWhiteSpace(answer)) { continue }
- if (SUtils.NormalizeSpaces(SUtils.RemoveUnnecesarySpaces(correct)).includes(answer)) // if the correct answer includes the current answer
- {
+ if (SUtils.NormalizeSpaces(SUtils.RemoveUnnecesarySpaces(correct)).includes(answer)) { // if the correct answer includes the current answer
toColor.push(i) // adding the index
type = MPM.GetInputType(answers, i) // setting the type
}
}
}
- if (results[0].match == 100) // if the result is 100% correct
- {
- if (type !== 'radio' || toColor.length == 1) // TODO why not radio
- {
- for (var i = 0; i < toColor.length; i++) // going through "toColor"
- { answers[toColor[i]].style.backgroundColor = '#8cff66' }
+ if (results[0].match === 100) { // if the result is 100% correct
+ if (type !== 'radio' || toColor.length === 1) { // TODO why not radio
+ for (let i = 0; i < toColor.length; i++) { // going through "toColor"
+ answers[toColor[i]].style.backgroundColor = '#8cff66'
+ }
}
} // and coloring the correct index
}
- } catch (e) // catching errors. Sometimes there are random errors, wich i did not test, but they are rare, and does not break the main script.
- {
+ } catch (e) { // catching errors. Sometimes there are random errors, wich i did not test, but they are rare, and does not break the main script.
Log('script error at highlightin answer: ' + e.message)
}
}
@@ -1634,10 +1627,9 @@
var defMargin = '0px 5px 0px 5px'
var isSimpleMessage = false
var simpleMessageText = ''
- if (msgItem.isSimple) // parsing msgItem for easier use
- {
+ if (msgItem.isSimple) { // parsing msgItem for easier use
simpleMessageText = msgItem.m
- if (simpleMessageText == '') {
+ if (simpleMessageText === '') {
return
}
msgItem = [
@@ -1650,13 +1642,11 @@
var appedtTo = document.body // will be appended here
var width = window.innerWidth - window.innerWidth / 6 // with of the box
- var startFromLeft = window.innerWidth / 2 - width / 2 // dont change this
var startFromTop = 25 // top distance
var mainDiv = document.createElement('div') // the main divider, wich items will be attached to
mainDiv.setAttribute('id', 'messageMainDiv')
- if (funct) // if there is a function as parameter
- {
+ if (funct) { // if there is a function as parameter
addEventListener(mainDiv, 'click', funct) // adding it as click
}
// lotsa crap style
@@ -1684,8 +1674,7 @@
mesageNode.style.margin = defMargin // fancy margin
}
mainDiv.appendChild(simpleMessageParagrapg) // adding text box to main div
- } else // if its a fucking complicated message
- {
+ } else { // if its a fucking complicated message
// TABLE SETUP ------------------------------------------------------------------------------------------------------------
var table = document.createElement('table')
table.style.width = '100%'
@@ -1713,8 +1702,7 @@
var percentTextBox = CreateNodeWithText(percentTextCell, '')
percentTextBox.setAttribute('id', 'percentTextBox')
- if (matchPercent) // if match percent param is not null
- {
+ if (matchPercent) { // if match percent param is not null
percentTextBox.innerText = matchPercent + '%'
}
// NUMBER SETUP -----------------------------------------------------------------------------------------------------
@@ -1729,12 +1717,11 @@
var currItem = 0
var currRelevantQuestion = 0
- function GetRelevantQuestion () // returns the currItemth questions currRelevantQuestionth relevant question
- {
+ const GetRelevantQuestion = () => { // returns the currItemth questions currRelevantQuestionth relevant question
return msgItem[currItem][currRelevantQuestion]
}
- function ChangeCurrItemIndex (to) {
+ const ChangeCurrItemIndex = (to) => {
currItem += to
if (currItem < 0) {
currItem = 0
@@ -1745,7 +1732,7 @@
currRelevantQuestion = 0
}
- function ChangeCurrRelevantQuestionIndex (to) {
+ const ChangeCurrRelevantQuestionIndex = (to) => {
currRelevantQuestion += to
if (currRelevantQuestion < 0) {
currRelevantQuestion = 0
@@ -1755,10 +1742,10 @@
}
}
- function SetQuestionText () {
+ const SetQuestionText = () => {
var relevantQuestion = GetRelevantQuestion()
questionTextElement.innerText = relevantQuestion.m
- if (currItem == 0 && currRelevantQuestion == 0) {
+ if (currItem === 0 && currRelevantQuestion === 0) {
numberTextBox.innerText = (currRelevantQuestion + 1) + '.'
} else {
numberTextBox.innerText = (currItem + 1) + './' + (currRelevantQuestion + 1) + '.'
@@ -1786,10 +1773,9 @@
})
}
// deciding if has multiple questions ------------------------------------------------------------------------------------------------
- if (msgItem.length == 1) {
+ if (msgItem.length === 1) {
SetQuestionText()
- } else // if there are multiple items to display
- {
+ } else { // if there are multiple items to display
// PREV QUESTION BUTTON ------------------------------------------------------------------------------------------------------------
var prevButton = CreateNodeWithText(prevQuestionCell, '^', 'button')
prevButton.style.margin = buttonMargin // fancy margin
@@ -1815,21 +1801,20 @@
// setting some events
// addEventListener(window, 'scroll', function () {
- // mainDiv.style.top = (pageYOffset + startFromTop) + 'px';
+ // mainDiv.style.top = (pageYOffset + startFromTop) + 'px';
// })
addEventListener(window, 'resize', function () {
mainDiv.style.left = (window.innerWidth - width) / 2 + 'px'
})
var timeOut
- if (timeout && timeout > 0) // setting timeout if not zero or null
- {
+ if (timeout && timeout > 0) { // setting timeout if not zero or null
timeOut = setTimeout(function () {
mainDiv.parentNode.removeChild(mainDiv)
}, timeout * 1000)
}
// middle click close event listener
addEventListener(mainDiv, 'mousedown', function (e) {
- if (e.which == 2) {
+ if (e.which === 2) {
mainDiv.parentNode.removeChild(mainDiv)
if (timeOut) {
clearTimeout(timeOut)
@@ -1888,7 +1873,7 @@
// passive mode stuff
var questionsTickBox = document.createElement('input')
questionsTickBox.type = 'checkbox'
- questionsTickBox.checked = GM_getValue('skipLoad')
+ questionsTickBox.checked = getVal('skipLoad')
questionsTickBox.style.position = ''
questionsTickBox.style.left = 10 + 'px'
questionsTickBox.style.margin = '5px 5px 5px 5px' // fancy margin
@@ -1897,9 +1882,9 @@
menuButtonDiv.appendChild(questionsTickBox) // adding to main div
questionsTickBox.addEventListener('click', function () {
- GM_setValue('skipLoad', questionsTickBox.checked)
+ setVal('skipLoad', questionsTickBox.checked)
var msg = ''
- if (GM_getValue('skipLoad')) { msg = 'Passzív mód bekapcsolva, mostantól kérdések nem lesznek betöltve/lekérve.' } else { msg = 'Passzív mód kikapcsolva, frissíts az érvénybe lépéshez!' }
+ if (getVal('skipLoad')) { msg = 'Passzív mód bekapcsolva, mostantól kérdések nem lesznek betöltve/lekérve.' } else { msg = 'Passzív mód kikapcsolva, frissíts az érvénybe lépéshez!' }
ShowMessage({
m: msg,
@@ -1951,52 +1936,103 @@
tbl.style.width = '98%'
// adding headers ---------------------------------------------------------------------------------------------------------------
- var subjTable = document.createElement('table')
+ var subjTable = document.createElement('div')
subjTable.style.margin = fiveMargin
subjTable.style.textAlign = 'left'
subjTable.style.width = '98%'
- var tr = subjTable.insertRow()
- var header1 = tr.insertCell()
+ // var tr = subjTable.insertRow()
+ // var header1 = tr.insertCell()
- var headerSubjInfoParagraph = CreateNodeWithText(header1, 'Tárgynév [darab kérdés]', 'center')
- headerSubjInfoParagraph.style.margin = fiveMargin // fancy margin
+ // var headerSubjInfoParagraph = CreateNodeWithText(header1, 'Tárgynév [darab kérdés]', 'center')
+ // headerSubjInfoParagraph.style.margin = fiveMargin // fancy margin
- var header2 = tr.insertCell()
- var headerSubjInfoParagraph = CreateNodeWithText(header2, 'Aktív')
- headerSubjInfoParagraph.style.margin = fiveMargin // fancy margin
+ // var header2 = tr.insertCell()
+ // var headerSubjInfoParagraph2 = CreateNodeWithText(header2, 'Aktív')
+ // headerSubjInfoParagraph2.style.margin = fiveMargin // fancy margin
if (data && data.length > 0) {
- for (let i = 0; i < data.length; i++) {
- var subjRow = subjTable.insertRow()
- subjRow.style.border = '1px solid #131319'
+ let grouped = data.Subjects.reduce((res, s) => {
+ let sName = s.getSubjNameWithoutYear()
+ if (sName) {
+ if (!res[sName]) {
+ res[sName] = []
+ }
+ res[sName].push(s)
+ } else {
+ res.others.push(s)
+ }
+ return res
+ }, {
+ others: []
+ })
- var td = subjRow.insertCell()
- var text = data.Subjects[i].Name
- if (data.Subjects[i].length != 0) { text += ' [ ' + data.Subjects[i].length + 'db ]' }
+ let collapsibles = []
- var textBox = CreateNodeWithText(td, text)
+ Object.entries(grouped).forEach(([subjName, subjGroup]) => {
+ let b = CreateNodeWithText(subjTable, subjName, 'button')
+ b.style.backgroundColor = '#222d32'
+ b.style.color = '#ffffff'
+ b.style.cursor = 'pointer'
+ b.style.padding = '5px'
+ b.style.width = '100%'
+ b.style.border = 'none'
+ b.style.textAlign = 'left'
+ b.style.outline = 'none'
+ collapsibles.push(b)
- textBox.style.margin = fiveMargin // fancy margin
+ let content = document.createElement('div')
+ content.style.padding = '0 18px'
+ content.style.overflow = 'hidden'
+ content.style.backgroundColor = '#222d32'
+ content.style.borderColor = '#212127'
+ content.style.borderStyle = 'solid'
+ content.style.borderWidth = '5px'
+ let ifGroupActive = subjGroup.some((x) => {
+ return x.getIfActive()
+ })
+ content.style.display = ifGroupActive ? 'block' : 'none'
- td = subjRow.insertCell()
- var checkbox = document.createElement('input') // new paragraph
- checkbox.type = 'checkbox'
- checkbox.style.background = 'white'
- checkbox.style.margin =
- '5px 5px 5px 5px' // fancy margin
- td.appendChild(checkbox) // adding text box to main td
+ subjTable.appendChild(content)
- var active = data.GetIfActive(i)
- checkbox.checked = active
+ subjGroup.forEach((subj) => {
+ let tbl = document.createElement('table')
+ content.appendChild(tbl)
- checkbox.setAttribute('id', 'HelperTextNode' + i)
+ var row = tbl.insertRow()
+ let td = row.insertCell()
+ let text = subj.getYear() || subj.Name
+ if (subj.length !== 0) { text += ' [ ' + subj.length + 'db ]' }
+ CreateNodeWithText(td, text)
- checkbox.addEventListener('click', function () {
- var checked = document.getElementById('HelperTextNode' + i).checked
- data.ChangeActive(i, checked)
- }) // adding click
- }
+ td = row.insertCell()
+ let checkbox = document.createElement('input') // new paragraph
+ checkbox.type = 'checkbox'
+ checkbox.style.background = 'white'
+ checkbox.style.margin = '5px 5px 5px 5px' // fancy margin
+ td.appendChild(checkbox) // adding text box to main td
+
+ checkbox.checked = subj.active
+ let i = subj.getIndex()
+ checkbox.setAttribute('id', 'HelperTextNode' + i)
+ checkbox.addEventListener('click', function () {
+ var checked = document.getElementById('HelperTextNode' + i).checked
+ data.ChangeActive(i, checked)
+ }) // adding click
+ })
+ })
+
+ collapsibles.forEach((x) => {
+ x.addEventListener('click', function () {
+ this.classList.toggle('active')
+ var content = this.nextElementSibling
+ if (content.style.display === 'block') {
+ content.style.display = 'none'
+ } else {
+ content.style.display = 'block'
+ }
+ })
+ })
var scrollDiv = document.createElement('div')
scrollDiv.style.width = '100%'
@@ -2008,13 +2044,12 @@
var subjtblrow = tbl.insertRow()
var subjtbltd = subjtblrow.insertCell()
subjtbltd.appendChild(scrollDiv)
- } else // if no data
- {
+ } else { // if no data
var noDataRow = tbl.insertRow()
var noDataRowCell = noDataRow.insertCell()
- var textBox
+ let textBox
- if (GM_getValue('skipLoad')) {
+ if (getVal('skipLoad')) {
textBox = CreateNodeWithText(noDataRowCell,
'Passszív mód bekapcsolva. Kapcsold ki a kérdések betöltéséhez!'
)
@@ -2032,7 +2067,7 @@
var splashTickBox = document.createElement('input')
splashTickBox.type = 'checkbox'
- splashTickBox.checked = GM_getValue('showSplash') || false
+ splashTickBox.checked = getVal('showSplash') || false
splashTickBox.style.position = ''
// splashTickBox.style.background = "white";
splashTickBox.style.left = 10 + 'px'
@@ -2041,11 +2076,10 @@
splashTickboxCell.appendChild(splashTickBox) // adding to main div
splashTickBox.addEventListener('click', function () {
- GM_setValue('showSplash', splashTickBox.checked)
+ setVal('showSplash', splashTickBox.checked)
}) // adding clicktextNode
- var splashTickBoxTextSpan = CreateNodeWithText(splashTickboxCell,
- 'Üdvözlő üzenet mutatása minden oldalon', 'span')
+ CreateNodeWithText(splashTickboxCell, 'Üdvözlő üzenet mutatása minden oldalon', 'span')
// show questons tickbox -----------------------------------------------------------------------------------------------------------------------------
var questionTickboxRow = tbl.insertRow()
@@ -2053,7 +2087,7 @@
var questionsTickBox = document.createElement('input')
questionsTickBox.type = 'checkbox'
- questionsTickBox.checked = GM_getValue('showQuestions')
+ questionsTickBox.checked = getVal('showQuestions')
questionsTickBox.style.position = ''
// questionsTickBox.style.background = "white";
questionsTickBox.style.left = 10 + 'px'
@@ -2062,7 +2096,7 @@
questionTickboxCell.appendChild(questionsTickBox) // adding to main div
questionsTickBox.addEventListener('click', function () {
- GM_setValue('showQuestions', questionsTickBox.checked)
+ setVal('showQuestions', questionsTickBox.checked)
if (!questionsTickBox.checked) {
ShowMessage({
m: 'Szinte mindég jó az talált válasz a kérdésre, de attól még könnyen előfordulhat, hogy rosz kérdésre írja ki a választ! Ez a opció nélkül ezt az ellenőrzési lehetőséget nem tudod kihasználni',
@@ -2070,8 +2104,8 @@
}, 7)
}
}) // adding clicktextNode
- var questionsTickBoxTextSpan = CreateNodeWithText(questionTickboxCell,
- 'Kérdések mutatása válaszhoz', 'span')
+
+ CreateNodeWithText(questionTickboxCell, 'Kérdések mutatása válaszhoz', 'span')
// database mode listbox -----------------------------------------------------------------------------------------------------------------------------
var databasemodeListboxRow = tbl.insertRow()
@@ -2079,7 +2113,7 @@
var databasemodeListbox = document.createElement('select')
databasemodeListbox.type = 'checkbox'
- // databasemodeListbox.checked = GM_getValue("showSplash") || false;
+ // databasemodeListbox.checked = getVal("showSplash") || false;
databasemodeListbox.style.position = ''
// databasemodeListbox.style.background = "white";
databasemodeListbox.style.left = 10 + 'px'
@@ -2094,7 +2128,7 @@
databasemodeListbox.addEventListener('change', function (e) {
// sorry for using selectedindex :c
- GM_setValue('useNetDB', databasemodeListbox.selectedIndex)
+ setVal('useNetDB', databasemodeListbox.selectedIndex)
})
var uselocal = document.createElement('option')
@@ -2107,8 +2141,8 @@
usenetsafe.value = 0
databasemodeListbox.add(usenetsafe, 1)
- var selected = GM_getValue('useNetDB')
- if (selected != undefined) { databasemodeListbox.selectedIndex = selected }
+ var selected = getVal('useNetDB')
+ if (selected !== undefined) { databasemodeListbox.selectedIndex = selected }
var databasemodeListboxElement = document.createElement('span') // new paragraph
databasemodeListboxCell.appendChild(databasemodeListboxElement)
@@ -2146,11 +2180,11 @@
siteLink.innerText = 'Weboldal'
siteLink.addEventListener('click', function () {
- location.href = serverAdress + 'menuClick'
+ location.href = serverAdress + 'menuClick' // eslint-disable-line
})
// addEventListener(window, 'scroll', function () {
- // menuDiv.style.top = (pageYOffset + window.innerHeight / 3) + 'px';
+ // menuDiv.style.top = (pageYOffset + window.innerHeight / 3) + 'px';
// })
addEventListener(window, 'resize', function () {
menuDiv.style.left = window.innerWidth / 2 + 'px'
@@ -2166,7 +2200,7 @@
}
function EscClose (e) {
- if (e.keyCode == 27) { CloseMenu() }
+ if (e.keyCode === 27) { CloseMenu() }
}
function CloseMenu () {
@@ -2180,20 +2214,6 @@
// : Generic utils {{{
- function RemoveMultipleItems (array) {
- var newArray = []
- for (var i = 0; i < array.length; i++) {
- var j = 0
- while (j < newArray.length && newArray[j] !== array[i]) {
- j++
- }
- if (j >= newArray.length) {
- newArray.push(array[i])
- }
- }
- return newArray
- }
-
function CreateNodeWithText (to, text, type) {
var paragraphElement = document.createElement(type || 'p') // new paragraph
var textNode = document.createTextNode(text)
@@ -2204,7 +2224,7 @@
function SendXHRMessage (message) {
var url = serverAdress + 'isAdding'
- GM_xmlhttpRequest({
+ xmlhttpRequest({
method: 'POST',
url: url,
data: message,
@@ -2227,7 +2247,7 @@
// shows some neat help
function ShowHelp () {
- GM_openInTab(serverAdress + 'manual', {
+ openInTab(serverAdress + 'manual', {
active: true
})
}
@@ -2256,5 +2276,4 @@
// O deepest wound of all that he should die
// On that darkest day.
-
})();