mirror of
https://gitlab.com/MrFry/moodle-test-userscript
synced 2025-04-01 20:22:48 +02:00
Removed passive mode, added new pw button
This commit is contained in:
parent
089f6d3732
commit
f8d4bf2a41
1 changed files with 42 additions and 61 deletions
101
stable.user.js
101
stable.user.js
|
@ -21,7 +21,7 @@
|
|||
|
||||
// ==UserScript==
|
||||
// @name Moodle/Elearning/KMOOC test help
|
||||
// @version 2.0.1.5
|
||||
// @version 2.0.1.6
|
||||
// @description Online Moodle/Elearning/KMOOC test help
|
||||
// @author MrFry
|
||||
// @match https://elearning.uni-obuda.hu/main/*
|
||||
|
@ -61,9 +61,7 @@
|
|||
|
||||
var addEventListener // add event listener function
|
||||
let serverAdress = 'https://qmining.frylabs.net/'
|
||||
// const serverAdress = 'http://localhost:8080/'
|
||||
let apiAdress = 'https://api.frylabs.net/'
|
||||
// const apiAdress = 'http://localhost:80/'
|
||||
const ircAddress = 'https://kiwiirc.com/nextclient/irc.sub.fm/#qmining'
|
||||
|
||||
// forcing pages for testing. unless you test, do not set these to true!
|
||||
|
@ -101,20 +99,18 @@
|
|||
websiteBugreport: 'Weboldal / Bug report',
|
||||
contribute: 'Contribute',
|
||||
donate: 'Donate',
|
||||
passiveTooltip: 'Ha erre kattintasz akkor a script átálítja a neptunban a hallgatói státuszod passzívra',
|
||||
retry: 'Újrapróbálás',
|
||||
ircButton: 'IRC',
|
||||
invalidPW: 'Hibás jelszó: ',
|
||||
search: 'Keresés ...',
|
||||
loading: 'Betöltés ...',
|
||||
login: 'Belépés',
|
||||
requestPW: 'Jelszó kérése',
|
||||
requestPWInsteadOfLogin: 'Jelszó igénylés',
|
||||
contributeTitle: 'Hozzájárulás a script és weboldal fejleszétéshez',
|
||||
newPWTitle: 'Új jelszó új felhasználónak',
|
||||
pwRequest: 'Új jelszó',
|
||||
noServer: 'Nem elérhető a szerver!',
|
||||
noUser: 'Nem vagy bejelentkezve!',
|
||||
passiveModeActivated: 'Passzív mód bekapcsolva, nem lesz mostantól a szerver piszkálva',
|
||||
passiveModeDeactivated: 'Passzív mód kikapcsolva, frissíts az érvénybe lépéshez!',
|
||||
passiveMode: 'Passzív mód',
|
||||
passiveModeMenuBoxText: 'Passzív mód aktív',
|
||||
noServerConsoleMessage: `Nem elérhető a szerver, vagy kis eséllyel kezeletlen hiba történt! Ha elérhető a weboldal, akkor ott meg bírod nézni a kérdéseket itt: ${serverAdress}legacy`
|
||||
}
|
||||
|
||||
|
@ -747,10 +743,8 @@
|
|||
}
|
||||
VersionActions()
|
||||
if (!url.includes('.pdf')) { ShowMenu() }
|
||||
if (!getVal('skipLoad')) {
|
||||
ConnectToServer(AfterLoad)
|
||||
}
|
||||
}
|
||||
|
||||
function Auth (pw) {
|
||||
SendXHRMessage('login', { pw: pw, script: true })
|
||||
|
@ -758,7 +752,7 @@
|
|||
if (res.result === 'success') {
|
||||
ConnectToServer(AfterLoad)
|
||||
ClearAllMessages()
|
||||
setPassiveButtonState(false)
|
||||
resetMenu()
|
||||
} else {
|
||||
SafeGetElementById('infoMainDiv', (elem) => {
|
||||
elem.innerText = texts.invalidPW + pw
|
||||
|
@ -767,6 +761,24 @@
|
|||
})
|
||||
}
|
||||
|
||||
function resetMenu () {
|
||||
SafeGetElementById('menuButtonDiv', (elem) => {
|
||||
elem.style.backgroundColor = '#262626'
|
||||
})
|
||||
SafeGetElementById('ircButton', (elem) => {
|
||||
elem.style.display = 'none'
|
||||
})
|
||||
SafeGetElementById('retryButton', (elem) => {
|
||||
elem.style.display = 'none'
|
||||
})
|
||||
SafeGetElementById('loginDiv', (elem) => {
|
||||
elem.style.display = 'none'
|
||||
})
|
||||
SafeGetElementById('infoMainDiv', (elem) => {
|
||||
elem.innerText = texts.loading
|
||||
})
|
||||
}
|
||||
|
||||
function ConnectToServer (cwith) {
|
||||
ClearAllMessages()
|
||||
GetXHRInfos().then((inf) => {
|
||||
|
@ -791,6 +803,9 @@
|
|||
})
|
||||
SafeGetElementById('infoMainDiv', (elem) => {
|
||||
elem.innerText = texts.noUser
|
||||
if (getVal('clientId')) {
|
||||
elem.innerText += ` (${getVal('clientId')})`
|
||||
}
|
||||
})
|
||||
SafeGetElementById('loginDiv', (elem) => {
|
||||
elem.style.display = ''
|
||||
|
@ -1521,6 +1536,7 @@
|
|||
// site link ----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
let contributeLink = CreateNodeWithText(buttonCell, texts.contribute, 'button')
|
||||
contributeLink.title = texts.contributeTitle
|
||||
SetStyle(contributeLink, buttonStyle)
|
||||
|
||||
contributeLink.addEventListener('click', function () {
|
||||
|
@ -1529,6 +1545,18 @@
|
|||
})
|
||||
})
|
||||
|
||||
// pw request ----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
let pwRequest = CreateNodeWithText(buttonCell, texts.pwRequest, 'button')
|
||||
pwRequest.title = texts.newPWTitle
|
||||
SetStyle(pwRequest, buttonStyle)
|
||||
|
||||
pwRequest.addEventListener('click', function () {
|
||||
openInTab(serverAdress + 'pwRequest', {
|
||||
active: true
|
||||
})
|
||||
})
|
||||
|
||||
// site link ----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
let siteLink = CreateNodeWithText(buttonCell, texts.websiteBugreport, 'button')
|
||||
|
@ -1587,7 +1615,7 @@
|
|||
const clientId = getVal('clientId')
|
||||
if (clientId && clientId.toString()[0] !== '0') {
|
||||
loginInput.value = clientId || ''
|
||||
loginButton.innerText = texts.requestPW
|
||||
loginButton.innerText = texts.requestPWInsteadOfLogin
|
||||
}
|
||||
loginDiv.appendChild(loginInput)
|
||||
loginDiv.appendChild(loginButton)
|
||||
|
@ -1637,60 +1665,13 @@
|
|||
menuButtonDiv.style.top = (window.innerHeight - 70) + 'px'
|
||||
})
|
||||
|
||||
// passive button ----------------------------------------------------------------------------------------------------------------
|
||||
let passiveButton = CreateNodeWithText(buttonCell, texts.passiveMode, 'button')
|
||||
passiveButton.title = texts.passiveTooltip
|
||||
SetStyle(passiveButton, buttonStyle)
|
||||
|
||||
// APPEND EVERYTHING
|
||||
appedtTo.appendChild(menuButtonDiv)
|
||||
|
||||
setPassiveButtonState(getVal('skipLoad'))
|
||||
|
||||
passiveButton.addEventListener('click', function () {
|
||||
ClearAllMessages()
|
||||
let sl = !getVal('skipLoad')
|
||||
setVal('skipLoad', sl)
|
||||
setPassiveButtonState(sl, true)
|
||||
|
||||
if (sl) {
|
||||
ShowMessage({
|
||||
m: texts.passiveModeActivated,
|
||||
isSimple: true
|
||||
}, 6)
|
||||
} else {
|
||||
ConnectToServer(AfterLoad)
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
Exception(e, 'script error at showing menu:')
|
||||
}
|
||||
}
|
||||
|
||||
function setPassiveButtonState (isPassive) {
|
||||
SafeGetElementById('menuButtonDiv', (elem) => {
|
||||
elem.style.backgroundColor = '#262626'
|
||||
})
|
||||
SafeGetElementById('ircButton', (elem) => {
|
||||
elem.style.display = 'none'
|
||||
})
|
||||
SafeGetElementById('retryButton', (elem) => {
|
||||
elem.style.display = 'none'
|
||||
})
|
||||
SafeGetElementById('loginDiv', (elem) => {
|
||||
elem.style.display = 'none'
|
||||
})
|
||||
if (!isPassive) {
|
||||
SafeGetElementById('infoMainDiv', (elem) => {
|
||||
elem.innerText = texts.loading
|
||||
})
|
||||
} else {
|
||||
SafeGetElementById('infoMainDiv', (elem) => {
|
||||
elem.innerText = texts.passiveModeMenuBoxText
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// : }}}
|
||||
|
||||
// : Generic utils {{{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue