From f34449c9600dfdf92ed429c8f7f5ccde607a9f98 Mon Sep 17 00:00:00 2001 From: MrFry Date: Tue, 8 Oct 2019 11:08:17 +0200 Subject: [PATCH] Stack simplification removing, more precise HasImage checking, Question getting small fix --- frame.js | 2 +- main.js | 26 ++++++-------------------- stable.js | 28 +++++++--------------------- 3 files changed, 14 insertions(+), 42 deletions(-) diff --git a/frame.js b/frame.js index 647a180..58375ae 100644 --- a/frame.js +++ b/frame.js @@ -21,7 +21,7 @@ // ==UserScript== // @name Moodle/Elearning/KMOOC test help -// @version 1.6.4.0 +// @version 1.6.4.1 // @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 266f47f..0252bfe 100644 --- a/main.js +++ b/main.js @@ -221,23 +221,7 @@ class StringUtils { } SimplifyStack (stack) { - stack = this.SimplifyQuery(stack) - let ns = '' - let adding = true - stack.split('').forEach((c) => { - if (c === '(') { - adding = false - } - - if (adding) { - ns += c - } - - if (c === ')') { - adding = true - } - }) - return ns + return this.SimplifyQuery(stack) } } @@ -263,7 +247,7 @@ class Question { } HasImage () { - return this.I !== undefined + return this.I !== undefined && (typeof this.I === 'string' || Array.isArray(this.I)) } IsComplete () { @@ -550,8 +534,10 @@ class QuestionsPageModell { Log('Some error with images') } - questions = questions.map((item, ind) => { - return SUtils.ReplaceCharsWithSpace(item, '\n') + questions = questions.map((item) => { + if (item) { + return SUtils.ReplaceCharsWithSpace(item, '\n') + } }) return { diff --git a/stable.js b/stable.js index 388535a..147b8bd 100644 --- a/stable.js +++ b/stable.js @@ -21,7 +21,7 @@ // ==UserScript== // @name Moodle/Elearning/KMOOC test help -// @version 1.6.4.0 +// @version 1.6.4.1 // @description Online Moodle/Elearning/KMOOC test help // @author MrFry // @match https://elearning.uni-obuda.hu/main/* @@ -239,23 +239,7 @@ } SimplifyStack (stack) { - stack = this.SimplifyQuery(stack) - let ns = '' - let adding = true - stack.split('').forEach((c) => { - if (c === '(') { - adding = false - } - - if (adding) { - ns += c - } - - if (c === ')') { - adding = true - } - }) - return ns + return this.SimplifyQuery(stack) } } @@ -281,7 +265,7 @@ } HasImage () { - return this.I !== undefined + return this.I !== undefined && (typeof this.I === 'string' || Array.isArray(this.I)) } IsComplete () { @@ -568,8 +552,10 @@ Log('Some error with images') } - questions = questions.map((item, ind) => { - return SUtils.ReplaceCharsWithSpace(item, '\n') + questions = questions.map((item) => { + if (item) { + return SUtils.ReplaceCharsWithSpace(item, '\n') + } }) return {