From e53ca9d87c57a58be360d4e6e5c2a70cf4a63c82 Mon Sep 17 00:00:00 2001 From: MrFry Date: Mon, 7 Oct 2019 11:00:26 +0200 Subject: [PATCH] Added error/stack sending, question simplifying bugfix --- main.js | 51 ++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/main.js b/main.js index 59f4f25..cc0f04c 100644 --- a/main.js +++ b/main.js @@ -189,15 +189,37 @@ class StringUtils { if (!value) { return } let mods = [ - this.RemoveSpecialChars, - this.RemoveUnnecesarySpaces, - this.QuestionPreProcessor, - this.RemoveAnswerLetters + this.RemoveSpecialChars.bind(this), + this.RemoveUnnecesarySpaces.bind(this), + this.QuestionPreProcessor.bind(this), + this.RemoveAnswerLetters.bind(this) ] - return mods.reduce((res, fn) => { + const reducer = (res, fn) => { return fn(res) - }, value) + } + + return mods.reduce(reducer, value) + } + + 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 } } @@ -834,10 +856,25 @@ function Main () { 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 () { - openInTab(serverAdress + 'lred', { + let path = 'lred' + try { + if (e.message || e.stack) { + path += '?' + } + if (e.message) { + path += 'msg:' + SUtils.SimplifyQuery(e.message) + '&' + } + if (e.stack) { + path += 'stack:' + SUtils.SimplifyStack(e.stack) + } + } catch (e) { + Exception(e, 'error at setting error stack/msg link') + } + openInTab(serverAdress + path, { active: true }) }) + Exception(e, 'script error at main:') } if (url.includes('eduplayer')) { AddVideoHotkeys(url) } // adding video hotkeys