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 {{{
|
||||
// ==UserScript==
|
||||
// @name Moodle/Elearning/KMOOC test help
|
||||
// @version 2.1.4.0
|
||||
// @version 2.1.4.2
|
||||
// @description Online Moodle/Elearning/KMOOC test help
|
||||
// @author MrFry
|
||||
// @match https://elearning.uni-obuda.hu/*
|
||||
|
@ -149,7 +149,6 @@
|
|||
var motd = ''
|
||||
var lastestVersion = ''
|
||||
var subjInfo
|
||||
let uiShowing = getVal('uishowing')
|
||||
// array, where elems are added to shadow-root, but its position should be at target.
|
||||
var updatableElements = [] // { elem: ..., target: ... }
|
||||
var elementUpdaterInterval = -1
|
||||
|
@ -1711,7 +1710,6 @@
|
|||
}
|
||||
VersionActions()
|
||||
if (!url.includes('.pdf')) {
|
||||
SetupMenu()
|
||||
ShowMenu()
|
||||
}
|
||||
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) {
|
||||
let isSimpleMessage = false
|
||||
let simpleMessageText = ''
|
||||
|
@ -2418,7 +2387,6 @@
|
|||
width: width + 'px',
|
||||
opacity: getVal(`${id}_opacity`),
|
||||
cursor: funct ? 'pointer' : 'move',
|
||||
display: uiShowing ? '' : 'none',
|
||||
})
|
||||
if (funct) {
|
||||
addEventListener(messageElem, 'click', funct)
|
||||
|
@ -2656,7 +2624,7 @@
|
|||
const id = 'scriptMenuDiv'
|
||||
scriptMenuDiv.setAttribute('id', id)
|
||||
SetStyle(scriptMenuDiv, {
|
||||
display: uiShowing ? 'flex' : 'none',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
width: '300px',
|
||||
height: '90px',
|
||||
|
@ -2936,7 +2904,7 @@
|
|||
function getPeerUrl(peer) {
|
||||
let protocol = 'https://'
|
||||
if (isDevel) {
|
||||
let protocol = 'http://'
|
||||
protocol = 'http://'
|
||||
}
|
||||
return protocol + peer.host + ':' + peer.port + '/'
|
||||
}
|
||||
|
@ -3034,9 +3002,10 @@
|
|||
function GetXHRInfos() {
|
||||
registerScript()
|
||||
const now = new Date().getTime()
|
||||
const lastCheck = getVal('lastInfoCheckTime')
|
||||
let lastCheck = getVal('lastInfoCheckTime')
|
||||
if (!lastCheck) {
|
||||
setVal('lastInfoCheckTime', 0)
|
||||
lastCheck = 0
|
||||
}
|
||||
|
||||
let lastInfo = { result: 'noLastInfo' }
|
||||
|
@ -3060,7 +3029,7 @@
|
|||
setVal('lastInfoCheckTime', now)
|
||||
resolve(merged)
|
||||
} catch (e) {
|
||||
log('Errro paring JSON in GetXHRInfos')
|
||||
log('Error paring JSON in GetXHRInfos')
|
||||
log({ infos: infos, hasNewMsg: hasNewMsg })
|
||||
log(e)
|
||||
reject(e)
|
||||
|
@ -3077,7 +3046,7 @@
|
|||
lastInfo = JSON.parse(getVal('lastInfo'))
|
||||
resolve(lastInfo)
|
||||
} catch (e) {
|
||||
log('Errro paring JSON in GetXHRInfos, when using old data!')
|
||||
log('Error paring JSON in GetXHRInfos, when using old data!')
|
||||
log(e)
|
||||
reject(e)
|
||||
}
|
||||
|
@ -3107,9 +3076,10 @@
|
|||
|
||||
function getPeers() {
|
||||
const now = new Date().getTime()
|
||||
const lastCheck = getVal('lastp2pchecktime')
|
||||
let lastCheck = getVal('lastp2pchecktime')
|
||||
if (!lastCheck) {
|
||||
setVal('lastp2pchecktime', 0)
|
||||
lastCheck = 0
|
||||
}
|
||||
|
||||
let lastp2pinfo = {}
|
||||
|
@ -3126,7 +3096,7 @@
|
|||
setVal('lastp2pchecktime', now)
|
||||
resolve(p2pinfoObj)
|
||||
} catch (e) {
|
||||
log('Errro paring JSON in getPeers')
|
||||
log('Error paring JSON in getPeers')
|
||||
log(p2pinfo)
|
||||
log(e)
|
||||
reject(e)
|
||||
|
@ -3143,7 +3113,7 @@
|
|||
lastp2pinfo = JSON.parse(getVal('lastp2pinfo'))
|
||||
resolve(lastp2pinfo)
|
||||
} catch (e) {
|
||||
log('Errro paring JSON in GetXHRInfos, when using old data!')
|
||||
log('Error paring JSON in getPeers, when using old data!')
|
||||
log(e)
|
||||
reject(e)
|
||||
}
|
||||
|
@ -3259,13 +3229,7 @@
|
|||
|
||||
// shows some neat help
|
||||
function ShowHelp(firstRun) {
|
||||
let q = '?tab=script'
|
||||
if (firstRun) {
|
||||
q += '&firstRun=true'
|
||||
} else {
|
||||
q += '&fromScript=true'
|
||||
}
|
||||
openInTab(serverAdress + q, {
|
||||
openInTab(serverAdress + 'faq', {
|
||||
active: true,
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue