mirror of
https://gitlab.com/MrFry/moodle-test-userscript
synced 2025-04-01 20:22:48 +02:00
Showing MOTD every day
This commit is contained in:
parent
d213f2516b
commit
2f8730e2c7
1 changed files with 16 additions and 4 deletions
|
@ -46,7 +46,7 @@
|
|||
// : Script header {{{
|
||||
// ==UserScript==
|
||||
// @name Moodle/Elearning/KMOOC test help
|
||||
// @version 2.1.3.6
|
||||
// @version 2.1.3.7
|
||||
// @description Online Moodle/Elearning/KMOOC test help
|
||||
// @author MrFry
|
||||
// @match https://elearning.uni-obuda.hu/*
|
||||
|
@ -120,7 +120,7 @@
|
|||
const forcedMatchString = isDevel ? 'default' : null
|
||||
// only one of these should be true for testing
|
||||
const forceTestPage = isDevel && false
|
||||
const forceResultPage = isDevel && true
|
||||
const forceResultPage = isDevel && false
|
||||
const forceDefaultPage = isDevel && false
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
|
@ -132,7 +132,7 @@
|
|||
let serverAdress = 'https://qmining.frylabs.net/'
|
||||
let apiAdress = 'https://api.frylabs.net/'
|
||||
|
||||
const motdShowCount = 3 /* Ammount of times to show motd */
|
||||
const motdShowCount = 5 /* Ammount of times to show motd */
|
||||
const messageOpacityDelta = 0.1
|
||||
const minMessageOpacity = 0.2
|
||||
let infoExpireTime = 60 * 5 // Every n seconds basic info should be loaded from server
|
||||
|
@ -1700,10 +1700,22 @@
|
|||
|
||||
// : UI handling {{{
|
||||
|
||||
function isNewDay() {
|
||||
const now = new Date()
|
||||
const lastLoad = getVal('lastLoadDate')
|
||||
|
||||
if (new Date(lastLoad).getDay() !== now.getDay()) {
|
||||
setVal('lastLoadDate', now.toString())
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
function shouldShowMotd() {
|
||||
if (!emptyOrWhiteSpace(motd)) {
|
||||
var prevmotd = getVal('motd')
|
||||
if (prevmotd !== motd) {
|
||||
if (prevmotd !== motd || isNewDay()) {
|
||||
setVal('motdcount', motdShowCount)
|
||||
setVal('motd', motd)
|
||||
return true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue