mirror of
https://gitlab.com/MrFry/moodle-test-userscript
synced 2025-04-01 20:22:48 +02:00
Merging master
This commit is contained in:
commit
cb9ea19699
2 changed files with 85 additions and 21 deletions
|
@ -25,6 +25,8 @@
|
||||||
// @author Yout
|
// @author Yout
|
||||||
// @match https://elearning.uni-obuda.hu/main/*
|
// @match https://elearning.uni-obuda.hu/main/*
|
||||||
// @match https://elearning.uni-obuda.hu/kmooc/*
|
// @match https://elearning.uni-obuda.hu/kmooc/*
|
||||||
|
// @match https://qmining.frylabs.net/*
|
||||||
|
// @match http://qmining.frylabs.net/*
|
||||||
// @match file:///*
|
// @match file:///*
|
||||||
// @grant GM_getResourceText
|
// @grant GM_getResourceText
|
||||||
// @grant GM_info
|
// @grant GM_info
|
||||||
|
|
104
stable.user.js
104
stable.user.js
|
@ -27,6 +27,8 @@
|
||||||
// @match https://elearning.uni-obuda.hu/main/*
|
// @match https://elearning.uni-obuda.hu/main/*
|
||||||
// @match https://elearning.uni-obuda.hu/kmooc/*
|
// @match https://elearning.uni-obuda.hu/kmooc/*
|
||||||
// @match https://mooc.unideb.hu/*
|
// @match https://mooc.unideb.hu/*
|
||||||
|
// @match https://qmining.frylabs.net/*
|
||||||
|
// @match http://qmining.frylabs.net/*
|
||||||
// @grant GM_getResourceText
|
// @grant GM_getResourceText
|
||||||
// @grant GM_info
|
// @grant GM_info
|
||||||
// @grant GM_getValue
|
// @grant GM_getValue
|
||||||
|
@ -72,6 +74,7 @@
|
||||||
const log = true
|
const log = true
|
||||||
|
|
||||||
const motdShowCount = 3 /* Ammount of times to show motd */
|
const motdShowCount = 3 /* Ammount of times to show motd */
|
||||||
|
const infoExpireTime = 60 // Every n seconds basic info should be loaded from server
|
||||||
var motd = ''
|
var motd = ''
|
||||||
var lastestVersion = ''
|
var lastestVersion = ''
|
||||||
var subjInfo
|
var subjInfo
|
||||||
|
@ -611,7 +614,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function AfterLoad () {
|
function AfterLoad () {
|
||||||
var url = location.href // eslint-disable-line
|
const url = location.href // eslint-disable-line
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ((url.includes('/quiz/') && url.includes('attempt.php')) || forceTestPage) { // if the current page is a test
|
if ((url.includes('/quiz/') && url.includes('attempt.php')) || forceTestPage) { // if the current page is a test
|
||||||
|
@ -652,8 +655,46 @@
|
||||||
// : Main logic stuff {{{
|
// : Main logic stuff {{{
|
||||||
|
|
||||||
// : Loading {{{
|
// : Loading {{{
|
||||||
|
function HandleQminingSite (url) {
|
||||||
|
try {
|
||||||
|
Array.from(document.getElementById('sideBarLinks').childNodes).forEach((link) => {
|
||||||
|
link.addEventListener('mousedown', () => {
|
||||||
|
FillFeedbackCID(url, link)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
FillFeedbackCID(url,
|
||||||
|
document.getElementById('sideBarLinks').getElementsByClassName('active')[0]
|
||||||
|
)
|
||||||
|
} catch (e) {
|
||||||
|
console.info('Error filling client ID input', e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function FillFeedbackCID (url, link) {
|
||||||
|
try {
|
||||||
|
if (link.id === 'feedback') {
|
||||||
|
const cidSetInterval = setInterval(() => {
|
||||||
|
const cid = document.getElementById('cid')
|
||||||
|
if (cid) {
|
||||||
|
cid.value = GetId()
|
||||||
|
window.clearInterval(cidSetInterval)
|
||||||
|
}
|
||||||
|
}, 100)
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.info('Error filling client ID input', e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function Init () {
|
function Init () {
|
||||||
|
const url = location.href // eslint-disable-line
|
||||||
|
|
||||||
|
if (url.includes(serverAdress.split('/')[2])) {
|
||||||
|
HandleQminingSite(url)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (false) { // eslint-disable-line
|
if (false) { // eslint-disable-line
|
||||||
setVal('version16', undefined)
|
setVal('version16', undefined)
|
||||||
setVal('version15', undefined)
|
setVal('version15', undefined)
|
||||||
|
@ -661,7 +702,6 @@
|
||||||
setVal('showQuestions', undefined)
|
setVal('showQuestions', undefined)
|
||||||
setVal('showSplash', undefined)
|
setVal('showSplash', undefined)
|
||||||
}
|
}
|
||||||
var url = location.href // eslint-disable-line
|
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
// event listener fuckery
|
// event listener fuckery
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
|
@ -1575,31 +1615,53 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function GetXHRInfos () {
|
function GetXHRInfos () {
|
||||||
const url = apiAdress +
|
const now = new Date().getTime()
|
||||||
'infos?version=true&motd=true&subjinfo=true&cversion=' +
|
const lastCheck = getVal('lastInfoCheckTime')
|
||||||
info().script.version +
|
if (!lastCheck) {
|
||||||
'&cid=' + GetId()
|
setVal('lastInfoCheckTime', now)
|
||||||
|
}
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
if (now > lastCheck + (infoExpireTime * 1000)) {
|
||||||
xmlhttpRequest({
|
console.log('GETTING DATA FROM SREVER')
|
||||||
method: 'GET',
|
setVal('lastInfoCheckTime', now)
|
||||||
url: url,
|
return new Promise((resolve, reject) => {
|
||||||
onload: function (response) {
|
const url = apiAdress +
|
||||||
try {
|
'infos?version=true&motd=true&subjinfo=true&cversion=' +
|
||||||
const res = JSON.parse(response.responseText)
|
info().script.version +
|
||||||
resolve(res)
|
'&cid=' + GetId()
|
||||||
} catch (e) {
|
|
||||||
Log('Errro paring JSON in GetXHRInfos')
|
xmlhttpRequest({
|
||||||
Log(e)
|
method: 'GET',
|
||||||
|
url: url,
|
||||||
|
onload: function (response) {
|
||||||
|
try {
|
||||||
|
const res = JSON.parse(response.responseText)
|
||||||
|
setVal('lastInfo', response.responseText)
|
||||||
|
resolve(res)
|
||||||
|
} catch (e) {
|
||||||
|
Log('Errro paring JSON in GetXHRInfos')
|
||||||
|
Log(e)
|
||||||
|
reject(e)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onerror: (e) => {
|
||||||
|
Log('Info get Error', e)
|
||||||
reject(e)
|
reject(e)
|
||||||
}
|
}
|
||||||
},
|
})
|
||||||
onerror: (e) => {
|
})
|
||||||
Log('Info get Error', e)
|
} else {
|
||||||
|
console.log('USING OLD')
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
try {
|
||||||
|
resolve(JSON.parse(getVal('lastInfo')))
|
||||||
|
} catch (e) {
|
||||||
|
Log('Errro paring JSON in GetXHRInfos, when using old data!')
|
||||||
|
Log(e)
|
||||||
reject(e)
|
reject(e)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function GetXHRQuestionAnswer (question) {
|
function GetXHRQuestionAnswer (question) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue