Added user specific motd support

This commit is contained in:
mrfry 2020-10-21 16:16:00 +02:00
parent 389e64e1ee
commit 146e352411

View file

@ -21,7 +21,7 @@
// ==UserScript== // ==UserScript==
// @name Moodle/Elearning/KMOOC test help // @name Moodle/Elearning/KMOOC test help
// @version 2.0.1.14 // @version 2.0.1.15
// @description Online Moodle/Elearning/KMOOC test help // @description Online Moodle/Elearning/KMOOC test help
// @author MrFry // @author MrFry
// @match https://elearning.uni-obuda.hu/main/* // @match https://elearning.uni-obuda.hu/main/*
@ -93,10 +93,11 @@
const motdShowCount = 3 /* Ammount of times to show motd */ const motdShowCount = 3 /* Ammount of times to show motd */
let infoExpireTime = 60 // Every n seconds basic info should be loaded from server let infoExpireTime = 60 // Every n seconds basic info should be loaded from server
var motd = '' var motd = ''
var userSpecificMotd = ''
var lastestVersion = '' var lastestVersion = ''
var subjInfo var subjInfo
// setVal('ISDEVEL', true) setVal('ISDEVEL', false)
if (getVal('ISDEVEL')) { if (getVal('ISDEVEL')) {
console.log('Moodle script running in developement mode!') console.log('Moodle script running in developement mode!')
@ -1159,6 +1160,7 @@
} }
lastestVersion = inf.version lastestVersion = inf.version
motd = inf.motd motd = inf.motd
userSpecificMotd = inf.userSpecificMotd
subjInfo = inf.subjinfo subjInfo = inf.subjinfo
overlay.querySelector( overlay.querySelector(
'#infoMainDiv' '#infoMainDiv'
@ -1260,12 +1262,14 @@
} }
} }
} }
const showUserSpecificMOTD = !!userSpecificMotd
let isNewVersionAvaible = let isNewVersionAvaible =
lastestVersion !== undefined && info().script.version !== lastestVersion lastestVersion !== undefined && info().script.version !== lastestVersion
var greetMsg = '' // message to show at the end var greetMsg = '' // message to show at the end
var timeout = null // the timeout. if null, it wont be hidden var timeout = null // the timeout. if null, it wont be hidden
if (isNewVersionAvaible || newVersion || showMOTD) { if (isNewVersionAvaible || newVersion || showMOTD || showUserSpecificMOTD) {
greetMsg = greetMsg =
'Moodle/Elearning/KMOOC segéd v. ' + info().script.version + '. ' 'Moodle/Elearning/KMOOC segéd v. ' + info().script.version + '. '
} }
@ -1287,6 +1291,10 @@
greetMsg += '\nMOTD:\n' + motd greetMsg += '\nMOTD:\n' + motd
timeout = null timeout = null
} }
if (showUserSpecificMOTD) {
greetMsg += '\nFelhasználó MOTD (ezt csak te látod):\n' + userSpecificMotd
timeout = null
}
ShowMessage( ShowMessage(
{ {
@ -1787,6 +1795,10 @@
simpleMessageParagrapg.appendChild(mesageNode) simpleMessageParagrapg.appendChild(mesageNode)
mesageNode.style.margin = defMargin // fancy margin 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 mainDiv.appendChild(simpleMessageParagrapg) // adding text box to main div
} else { } else {
// if its a fucking complicated message // if its a fucking complicated message
@ -2103,7 +2115,6 @@
SetStyle(loginButton, buttonStyle) SetStyle(loginButton, buttonStyle)
loginInput.addEventListener('keyup', e => { loginInput.addEventListener('keyup', e => {
console.log(e.target.value)
if (e.target.value === clientId) { if (e.target.value === clientId) {
loginButton.innerText = texts.requestPWInsteadOfLogin loginButton.innerText = texts.requestPWInsteadOfLogin
} else if (e.target.value !== '') { } else if (e.target.value !== '') {