mirror of
https://gitlab.com/MrFry/moodle-test-userscript
synced 2025-04-01 20:22:48 +02:00
removed ui hiding, first run fixes
This commit is contained in:
parent
b12e7a9a55
commit
e90eb6d3b9
1 changed files with 12 additions and 48 deletions
|
@ -46,7 +46,7 @@
|
||||||
// : Script header {{{
|
// : Script header {{{
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Moodle/Elearning/KMOOC test help
|
// @name Moodle/Elearning/KMOOC test help
|
||||||
// @version 2.1.4.0
|
// @version 2.1.4.2
|
||||||
// @description Online Moodle/Elearning/KMOOC test help
|
// @description Online Moodle/Elearning/KMOOC test help
|
||||||
// @author MrFry
|
// @author MrFry
|
||||||
// @match https://elearning.uni-obuda.hu/*
|
// @match https://elearning.uni-obuda.hu/*
|
||||||
|
@ -149,7 +149,6 @@
|
||||||
var motd = ''
|
var motd = ''
|
||||||
var lastestVersion = ''
|
var lastestVersion = ''
|
||||||
var subjInfo
|
var subjInfo
|
||||||
let uiShowing = getVal('uishowing')
|
|
||||||
// array, where elems are added to shadow-root, but its position should be at target.
|
// array, where elems are added to shadow-root, but its position should be at target.
|
||||||
var updatableElements = [] // { elem: ..., target: ... }
|
var updatableElements = [] // { elem: ..., target: ... }
|
||||||
var elementUpdaterInterval = -1
|
var elementUpdaterInterval = -1
|
||||||
|
@ -1711,7 +1710,6 @@
|
||||||
}
|
}
|
||||||
VersionActions()
|
VersionActions()
|
||||||
if (!url.includes('.pdf')) {
|
if (!url.includes('.pdf')) {
|
||||||
SetupMenu()
|
|
||||||
ShowMenu()
|
ShowMenu()
|
||||||
}
|
}
|
||||||
ConnectToServer()
|
ConnectToServer()
|
||||||
|
@ -2348,35 +2346,6 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function ToggleUIElements() {
|
|
||||||
const newVal = uiShowing ? 'none' : ''
|
|
||||||
SafeGetElementById(
|
|
||||||
'scriptMessage',
|
|
||||||
(elem) => {
|
|
||||||
elem.style.display = newVal
|
|
||||||
},
|
|
||||||
true
|
|
||||||
)
|
|
||||||
SafeGetElementById(
|
|
||||||
'scriptMenuDiv',
|
|
||||||
(elem) => {
|
|
||||||
elem.style.display = newVal
|
|
||||||
},
|
|
||||||
true
|
|
||||||
)
|
|
||||||
uiShowing = !uiShowing
|
|
||||||
setVal('uishowing', uiShowing)
|
|
||||||
}
|
|
||||||
|
|
||||||
function SetupMenu() {
|
|
||||||
document.addEventListener('keydown', (event) => {
|
|
||||||
if (event.ctrlKey && event.key === 'h') {
|
|
||||||
event.preventDefault()
|
|
||||||
ToggleUIElements()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function ShowMessage(msgItem, timeout, funct) {
|
function ShowMessage(msgItem, timeout, funct) {
|
||||||
let isSimpleMessage = false
|
let isSimpleMessage = false
|
||||||
let simpleMessageText = ''
|
let simpleMessageText = ''
|
||||||
|
@ -2418,7 +2387,6 @@
|
||||||
width: width + 'px',
|
width: width + 'px',
|
||||||
opacity: getVal(`${id}_opacity`),
|
opacity: getVal(`${id}_opacity`),
|
||||||
cursor: funct ? 'pointer' : 'move',
|
cursor: funct ? 'pointer' : 'move',
|
||||||
display: uiShowing ? '' : 'none',
|
|
||||||
})
|
})
|
||||||
if (funct) {
|
if (funct) {
|
||||||
addEventListener(messageElem, 'click', funct)
|
addEventListener(messageElem, 'click', funct)
|
||||||
|
@ -2656,7 +2624,7 @@
|
||||||
const id = 'scriptMenuDiv'
|
const id = 'scriptMenuDiv'
|
||||||
scriptMenuDiv.setAttribute('id', id)
|
scriptMenuDiv.setAttribute('id', id)
|
||||||
SetStyle(scriptMenuDiv, {
|
SetStyle(scriptMenuDiv, {
|
||||||
display: uiShowing ? 'flex' : 'none',
|
display: 'flex',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
width: '300px',
|
width: '300px',
|
||||||
height: '90px',
|
height: '90px',
|
||||||
|
@ -2936,7 +2904,7 @@
|
||||||
function getPeerUrl(peer) {
|
function getPeerUrl(peer) {
|
||||||
let protocol = 'https://'
|
let protocol = 'https://'
|
||||||
if (isDevel) {
|
if (isDevel) {
|
||||||
let protocol = 'http://'
|
protocol = 'http://'
|
||||||
}
|
}
|
||||||
return protocol + peer.host + ':' + peer.port + '/'
|
return protocol + peer.host + ':' + peer.port + '/'
|
||||||
}
|
}
|
||||||
|
@ -3034,9 +3002,10 @@
|
||||||
function GetXHRInfos() {
|
function GetXHRInfos() {
|
||||||
registerScript()
|
registerScript()
|
||||||
const now = new Date().getTime()
|
const now = new Date().getTime()
|
||||||
const lastCheck = getVal('lastInfoCheckTime')
|
let lastCheck = getVal('lastInfoCheckTime')
|
||||||
if (!lastCheck) {
|
if (!lastCheck) {
|
||||||
setVal('lastInfoCheckTime', 0)
|
setVal('lastInfoCheckTime', 0)
|
||||||
|
lastCheck = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
let lastInfo = { result: 'noLastInfo' }
|
let lastInfo = { result: 'noLastInfo' }
|
||||||
|
@ -3060,7 +3029,7 @@
|
||||||
setVal('lastInfoCheckTime', now)
|
setVal('lastInfoCheckTime', now)
|
||||||
resolve(merged)
|
resolve(merged)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log('Errro paring JSON in GetXHRInfos')
|
log('Error paring JSON in GetXHRInfos')
|
||||||
log({ infos: infos, hasNewMsg: hasNewMsg })
|
log({ infos: infos, hasNewMsg: hasNewMsg })
|
||||||
log(e)
|
log(e)
|
||||||
reject(e)
|
reject(e)
|
||||||
|
@ -3077,7 +3046,7 @@
|
||||||
lastInfo = JSON.parse(getVal('lastInfo'))
|
lastInfo = JSON.parse(getVal('lastInfo'))
|
||||||
resolve(lastInfo)
|
resolve(lastInfo)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log('Errro paring JSON in GetXHRInfos, when using old data!')
|
log('Error paring JSON in GetXHRInfos, when using old data!')
|
||||||
log(e)
|
log(e)
|
||||||
reject(e)
|
reject(e)
|
||||||
}
|
}
|
||||||
|
@ -3107,9 +3076,10 @@
|
||||||
|
|
||||||
function getPeers() {
|
function getPeers() {
|
||||||
const now = new Date().getTime()
|
const now = new Date().getTime()
|
||||||
const lastCheck = getVal('lastp2pchecktime')
|
let lastCheck = getVal('lastp2pchecktime')
|
||||||
if (!lastCheck) {
|
if (!lastCheck) {
|
||||||
setVal('lastp2pchecktime', 0)
|
setVal('lastp2pchecktime', 0)
|
||||||
|
lastCheck = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
let lastp2pinfo = {}
|
let lastp2pinfo = {}
|
||||||
|
@ -3126,7 +3096,7 @@
|
||||||
setVal('lastp2pchecktime', now)
|
setVal('lastp2pchecktime', now)
|
||||||
resolve(p2pinfoObj)
|
resolve(p2pinfoObj)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log('Errro paring JSON in getPeers')
|
log('Error paring JSON in getPeers')
|
||||||
log(p2pinfo)
|
log(p2pinfo)
|
||||||
log(e)
|
log(e)
|
||||||
reject(e)
|
reject(e)
|
||||||
|
@ -3143,7 +3113,7 @@
|
||||||
lastp2pinfo = JSON.parse(getVal('lastp2pinfo'))
|
lastp2pinfo = JSON.parse(getVal('lastp2pinfo'))
|
||||||
resolve(lastp2pinfo)
|
resolve(lastp2pinfo)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log('Errro paring JSON in GetXHRInfos, when using old data!')
|
log('Error paring JSON in getPeers, when using old data!')
|
||||||
log(e)
|
log(e)
|
||||||
reject(e)
|
reject(e)
|
||||||
}
|
}
|
||||||
|
@ -3259,13 +3229,7 @@
|
||||||
|
|
||||||
// shows some neat help
|
// shows some neat help
|
||||||
function ShowHelp(firstRun) {
|
function ShowHelp(firstRun) {
|
||||||
let q = '?tab=script'
|
openInTab(serverAdress + 'faq', {
|
||||||
if (firstRun) {
|
|
||||||
q += '&firstRun=true'
|
|
||||||
} else {
|
|
||||||
q += '&fromScript=true'
|
|
||||||
}
|
|
||||||
openInTab(serverAdress + q, {
|
|
||||||
active: true,
|
active: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue