From 146e352411d186b0911843bc0e8a53515a154964 Mon Sep 17 00:00:00 2001 From: mrfry Date: Wed, 21 Oct 2020 16:16:00 +0200 Subject: [PATCH] Added user specific motd support --- stable.user.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/stable.user.js b/stable.user.js index b0bc30e..1173fe3 100755 --- a/stable.user.js +++ b/stable.user.js @@ -21,7 +21,7 @@ // ==UserScript== // @name Moodle/Elearning/KMOOC test help -// @version 2.0.1.14 +// @version 2.0.1.15 // @description Online Moodle/Elearning/KMOOC test help // @author MrFry // @match https://elearning.uni-obuda.hu/main/* @@ -93,10 +93,11 @@ const motdShowCount = 3 /* Ammount of times to show motd */ let infoExpireTime = 60 // Every n seconds basic info should be loaded from server var motd = '' + var userSpecificMotd = '' var lastestVersion = '' var subjInfo - // setVal('ISDEVEL', true) + setVal('ISDEVEL', false) if (getVal('ISDEVEL')) { console.log('Moodle script running in developement mode!') @@ -1159,6 +1160,7 @@ } lastestVersion = inf.version motd = inf.motd + userSpecificMotd = inf.userSpecificMotd subjInfo = inf.subjinfo overlay.querySelector( '#infoMainDiv' @@ -1260,12 +1262,14 @@ } } } + const showUserSpecificMOTD = !!userSpecificMotd + let isNewVersionAvaible = lastestVersion !== undefined && info().script.version !== lastestVersion var greetMsg = '' // message to show at the end var timeout = null // the timeout. if null, it wont be hidden - if (isNewVersionAvaible || newVersion || showMOTD) { + if (isNewVersionAvaible || newVersion || showMOTD || showUserSpecificMOTD) { greetMsg = 'Moodle/Elearning/KMOOC segéd v. ' + info().script.version + '. ' } @@ -1287,6 +1291,10 @@ greetMsg += '\nMOTD:\n' + motd timeout = null } + if (showUserSpecificMOTD) { + greetMsg += '\nFelhasználó MOTD (ezt csak te látod):\n' + userSpecificMotd + timeout = null + } ShowMessage( { @@ -1787,6 +1795,10 @@ simpleMessageParagrapg.appendChild(mesageNode) mesageNode.style.margin = defMargin // fancy margin + Array.from(mesageNode.getElementsByTagName('a')).forEach(anchorElem => { + anchorElem.style.color = 'lightblue' + }) + mainDiv.appendChild(simpleMessageParagrapg) // adding text box to main div } else { // if its a fucking complicated message @@ -2103,7 +2115,6 @@ SetStyle(loginButton, buttonStyle) loginInput.addEventListener('keyup', e => { - console.log(e.target.value) if (e.target.value === clientId) { loginButton.innerText = texts.requestPWInsteadOfLogin } else if (e.target.value !== '') {