Last info JSON parsing error handling

This commit is contained in:
MrFry 2020-04-09 22:24:08 +02:00
parent 7dc12dbfa0
commit 6a638e0f78

View file

@ -21,7 +21,7 @@
// ==UserScript==
// @name Moodle/Elearning/KMOOC test help
// @version 2.0.1.1
// @version 2.0.1.2
// @description Online Moodle/Elearning/KMOOC test help
// @author MrFry
// @match https://elearning.uni-obuda.hu/main/*
@ -1716,7 +1716,11 @@
setVal('lastInfoCheckTime', now)
}
const lastInfo = JSON.parse(getVal('lastInfo'))
let lastInfo = { result: 'noLastInfo' }
try {
lastInfo = JSON.parse(getVal('lastInfo'))
} catch (e) {
}
if (lastInfo.result !== 'success' || now > lastCheck + (infoExpireTime * 1000)) {
return new Promise((resolve, reject) => {
const url = apiAdress +