From 234654a2e418661a9866cf927e76dc3dcce7adb9 Mon Sep 17 00:00:00 2001 From: mrfry Date: Mon, 16 Nov 2020 16:36:25 +0100 Subject: [PATCH 1/7] Added x button to msgs --- stable.user.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/stable.user.js b/stable.user.js index 482d0b9..6c8057c 100755 --- a/stable.user.js +++ b/stable.user.js @@ -2031,6 +2031,21 @@ } appedtTo.appendChild(mainDiv) // THE FINAL APPEND + const xButton = CreateNodeWithText(mainDiv, '❌', 'div') + const xButtonSize = 20 + SetStyle(xButton, { + position: 'absolute', + height: xButtonSize + 'px', + top: 0, + width: xButtonSize + 'px', + left: width - xButtonSize + 'px', + cursor: 'pointer', + }) + xButton.addEventListener('mousedown', e => { + e.stopPropagation() + mainDiv.parentNode.removeChild(mainDiv) + }) + // setting some events // addEventListener(window, 'scroll', function () { // mainDiv.style.top = (pageYOffset + startFromTop) + 'px'; From b5d83569a0a61dc1ec3f72e0478e49aad6e6752a Mon Sep 17 00:00:00 2001 From: mrfry Date: Mon, 16 Nov 2020 20:35:25 +0100 Subject: [PATCH 2/7] X button styling --- stable.user.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stable.user.js b/stable.user.js index 6c8057c..cb411c2 100755 --- a/stable.user.js +++ b/stable.user.js @@ -2032,8 +2032,9 @@ appedtTo.appendChild(mainDiv) // THE FINAL APPEND const xButton = CreateNodeWithText(mainDiv, '❌', 'div') - const xButtonSize = 20 + const xButtonSize = 40 SetStyle(xButton, { + margin: '5px', position: 'absolute', height: xButtonSize + 'px', top: 0, From 7736fc78046e564dc7cd9697b3130cabb7b4caa6 Mon Sep 17 00:00:00 2001 From: MrFry Date: Mon, 16 Nov 2020 20:36:37 +0100 Subject: [PATCH 3/7] Version inc --- stable.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stable.user.js b/stable.user.js index cb411c2..ff22ea8 100755 --- a/stable.user.js +++ b/stable.user.js @@ -21,7 +21,7 @@ // ==UserScript== // @name Moodle/Elearning/KMOOC test help -// @version 2.0.1.18 +// @version 2.0.1.19 // @description Online Moodle/Elearning/KMOOC test help // @author MrFry // @match https://elearning.uni-obuda.hu/main/* From 8ea6efec93612af493595a331fbafe36062f6af5 Mon Sep 17 00:00:00 2001 From: mrfry Date: Tue, 17 Nov 2020 13:09:17 +0100 Subject: [PATCH 4/7] Moved x button to seperate div, changed up/down arrows during test solving to fancy arrows --- stable.user.js | 60 +++++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/stable.user.js b/stable.user.js index cb411c2..750f05b 100755 --- a/stable.user.js +++ b/stable.user.js @@ -1851,6 +1851,25 @@ mainDiv.style.top = mousePosition.y + offset[1] + 'px' } }) + + const xrow = document.createElement('div') + SetStyle(xrow, { + height: '20px', + display: 'flex', + justifyContent: 'flex-end', + }) + mainDiv.appendChild(xrow) + + const xButton = CreateNodeWithText(xrow, '❌', 'div') + SetStyle(xButton, { + margin: '5px', + cursor: 'pointer', + }) + xButton.addEventListener('mousedown', e => { + e.stopPropagation() + mainDiv.parentNode.removeChild(mainDiv) + }) + // ------------------------------------------------------------------ var matchPercent = msgItem[0][0].p if (isSimpleMessage) { @@ -1966,16 +1985,17 @@ percentTextBox.innerText = relevantQuestion.p + '%' } + const buttonStyle = { + color: 'white', + backgroundColor: 'transparent', + margin: buttonMargin, + border: 'none', + fontSize: '30px', + cursor: 'pointer', + userSelect: 'none', + } var buttonMargin = '2px 2px 2px 2px' // uniform button margin if (msgItem[currItem].length > 1) { - const buttonStyle = { - color: 'white', - backgroundColor: 'transparent', - margin: buttonMargin, - border: 'none', - fontSize: '30px', - cursor: 'pointer', - } // PREV SUGG BUTTON ------------------------------------------------------------------------------------------------------------ var prevSuggButton = CreateNodeWithText( prevSuggestionCell, @@ -2009,8 +2029,8 @@ } else { // if there are multiple items to display // PREV QUESTION BUTTON ------------------------------------------------------------------------------------------------------------ - var prevButton = CreateNodeWithText(prevQuestionCell, '^', 'button') - prevButton.style.margin = buttonMargin // fancy margin + var prevButton = CreateNodeWithText(prevQuestionCell, '⬆️', 'div') + SetStyle(prevButton, buttonStyle) // event listener prevButton.addEventListener('click', function() { @@ -2018,8 +2038,8 @@ SetQuestionText() }) // NEXT QUESTION BUTTON ------------------------------------------------------------------------------------------------------------ - var nextButton = CreateNodeWithText(nextQuestionCell, 'ˇ', 'button') - nextButton.style.margin = buttonMargin // fancy margin + var nextButton = CreateNodeWithText(nextQuestionCell, '⬇️', 'div') + SetStyle(nextButton, buttonStyle) // event listener nextButton.addEventListener('click', function() { @@ -2031,22 +2051,6 @@ } appedtTo.appendChild(mainDiv) // THE FINAL APPEND - const xButton = CreateNodeWithText(mainDiv, '❌', 'div') - const xButtonSize = 40 - SetStyle(xButton, { - margin: '5px', - position: 'absolute', - height: xButtonSize + 'px', - top: 0, - width: xButtonSize + 'px', - left: width - xButtonSize + 'px', - cursor: 'pointer', - }) - xButton.addEventListener('mousedown', e => { - e.stopPropagation() - mainDiv.parentNode.removeChild(mainDiv) - }) - // setting some events // addEventListener(window, 'scroll', function () { // mainDiv.style.top = (pageYOffset + startFromTop) + 'px'; From 4243f26695e2e392676f8cbf0f3d846530b7e381 Mon Sep 17 00:00:00 2001 From: mrfry Date: Tue, 17 Nov 2020 13:10:09 +0100 Subject: [PATCH 5/7] Version inc --- stable.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stable.user.js b/stable.user.js index 750f05b..8c88755 100755 --- a/stable.user.js +++ b/stable.user.js @@ -21,7 +21,7 @@ // ==UserScript== // @name Moodle/Elearning/KMOOC test help -// @version 2.0.1.18 +// @version 2.0.1.20 // @description Online Moodle/Elearning/KMOOC test help // @author MrFry // @match https://elearning.uni-obuda.hu/main/* From 3cc6a915db6439a91da82eb81ddac477bd0caf63 Mon Sep 17 00:00:00 2001 From: mrfry Date: Tue, 17 Nov 2020 13:59:30 +0100 Subject: [PATCH 6/7] Moving overlay elements to target every seconds, so it wont slip --- stable.user.js | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/stable.user.js b/stable.user.js index 8c88755..5ef30e2 100755 --- a/stable.user.js +++ b/stable.user.js @@ -101,6 +101,11 @@ var lastestVersion = '' var subjInfo + // array, where elems are added to shadow-root, but its position should be at target. + var updatableElements = [] // { elem: ..., target: ... } + var elementUpdaterInterval = -1 + const overlayElemUpdateInterval = 2 // seconds + if (getVal('ISDEVEL')) { console.log('Moodle script running in developement mode!') infoExpireTime = 1 @@ -362,24 +367,33 @@ overlay.appendChild(toAppend) } - function createHoverOver(target) { + function createHoverOver(appendTo) { const overlayElement = document.createElement('div') overlay.append(overlayElement) - let currX, currY, currWidth, currHeight - let { left, top, width, height } = target.getBoundingClientRect() - left += window.scrollX - top += window.scrollY - SetStyle(overlayElement, { - pointerEvents: 'none', - userSelect: 'none', - position: 'absolute', - zIndex: 999999, - top: top + 'px', - left: left + 'px', - width: width + 'px', - height: height - 10 + 'px', - }) + updatableElements.push({ elem: overlayElement, target: appendTo }) + + if (elementUpdaterInterval === -1) { + elementUpdaterInterval = setInterval(() => { + updatableElements.forEach(({ elem, target }) => { + let currX, currY, currWidth, currHeight + let { left, top, width, height } = target.getBoundingClientRect() + left += window.scrollX + top += window.scrollY + + SetStyle(elem, { + pointerEvents: 'none', + userSelect: 'none', + position: 'absolute', + zIndex: 999999, + top: top + 'px', + left: left + 'px', + width: width + 'px', + height: height - 10 + 'px', + }) + }) + }, overlayElemUpdateInterval * 1000) + } return overlayElement } From dc07c903d39003a5cc13302a9ee6e6e3e0b6ee17 Mon Sep 17 00:00:00 2001 From: mrfry Date: Tue, 17 Nov 2020 13:59:41 +0100 Subject: [PATCH 7/7] Version inc --- stable.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stable.user.js b/stable.user.js index 5ef30e2..477f057 100755 --- a/stable.user.js +++ b/stable.user.js @@ -21,7 +21,7 @@ // ==UserScript== // @name Moodle/Elearning/KMOOC test help -// @version 2.0.1.20 +// @version 2.0.1.21 // @description Online Moodle/Elearning/KMOOC test help // @author MrFry // @match https://elearning.uni-obuda.hu/main/*