From 4386dc72b55baa4c7541b0dd18b532d23357c83d Mon Sep 17 00:00:00 2001 From: mrfry Date: Wed, 16 Feb 2022 19:24:46 +0100 Subject: [PATCH] Removed number before kgk questions, code formatting --- stable.user.js | 54 +++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/stable.user.js b/stable.user.js index e3a00fe..4c18c69 100755 --- a/stable.user.js +++ b/stable.user.js @@ -46,7 +46,7 @@ // : Script header {{{ // ==UserScript== // @name Moodle/Elearning/KMOOC test help -// @version 2.1.3.2 +// @version 2.1.3.3 // @description Online Moodle/Elearning/KMOOC test help // @author MrFry // @match https://elearning.uni-obuda.hu/* @@ -147,7 +147,7 @@ const overlayElemUpdateInterval = 2 // seconds if (isDevel) { - log('Moodle script running in developement mode!') + warn('Moodle script running in developement mode!') infoExpireTime = 1 serverAdress = 'http://localhost:8080/' apiAdress = 'http://localhost:8080/' @@ -1047,8 +1047,8 @@ } function HandleKGKResults(url) { - const tableChilds = document.getElementsByTagName('table')[0].childNodes[0] - .childNodes + const tableChilds = + document.getElementsByTagName('table')[0].childNodes[0].childNodes const question = removeUnnecesarySpaces( tableChilds[0].innerText.split(':')[1] ) @@ -1066,7 +1066,9 @@ location: url, quiz: [ { - Q: question, + Q: question.includes('.') + ? question.split('.').splice(1).join('.').trim() + : question, A: answer, data: { type: 'simple', @@ -1077,6 +1079,7 @@ ], } + log(sentData) post('isAdding', sentData).then((res) => { ShowSaveQuizDialog(res.success, sentData, res.totalNewQuestions) }) @@ -2055,7 +2058,7 @@ Array.from(messageNode.childNodes).forEach((node) => { if (node.tagName === 'A') { - let linkNode = document.createElement('span') + const linkNode = document.createElement('span') SetStyle(linkNode, { color: 'lightblue', textDecoration: 'underline', @@ -2084,21 +2087,25 @@ } let currOpacity = getVal(`${elem.id}_opacity`) || 1 - elem.addEventListener('wheel', (e) => { - e.preventDefault() - const isUp = e.deltaY < 0 - if (isUp) { - if (currOpacity + messageOpacityDelta <= 1) { - currOpacity = currOpacity + messageOpacityDelta + elem.addEventListener( + 'wheel', + (e) => { + e.preventDefault() + const isUp = e.deltaY < 0 + if (isUp) { + if (currOpacity + messageOpacityDelta <= 1) { + currOpacity = currOpacity + messageOpacityDelta + } + } else { + if (currOpacity - messageOpacityDelta > minMessageOpacity) { + currOpacity = currOpacity - messageOpacityDelta + } } - } else { - if (currOpacity - messageOpacityDelta > minMessageOpacity) { - currOpacity = currOpacity - messageOpacityDelta - } - } - elem.style.opacity = currOpacity - setVal(`${elem.id}_opacity`, currOpacity) - }) + elem.style.opacity = currOpacity + setVal(`${elem.id}_opacity`, currOpacity) + }, + { capture: true } + ) } function addMoveEventListener(elem) { @@ -2364,11 +2371,8 @@ '.' } - result.msgContainer.child.leftSideDiv.child.matchPercent.elem.innerText = isNaN( - getCurrMsg().p - ) - ? '' - : getCurrMsg().p + '%' + result.msgContainer.child.leftSideDiv.child.matchPercent.elem.innerText = + isNaN(getCurrMsg().p) ? '' : getCurrMsg().p + '%' result.msgContainer.child.msgDiv.elem.innerText = getCurrMsg().m } catch (e) {