-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
376 additions
and
632 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
"manifest_version": 3, | ||
"name": "__MSG_appName__", | ||
"description": "__MSG_appDesc__", | ||
"version": "3.10.5", | ||
"version": "3.11.0", | ||
"default_locale": "nl", | ||
"icons": { | ||
"16": "icons/[email protected]", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
"manifest_version": 3, | ||
"name": "__MSG_appName__", | ||
"description": "__MSG_appDesc__", | ||
"version": "3.10.5", | ||
"version": "3.11.0", | ||
"default_locale": "nl", | ||
"icons": { | ||
"16": "icons/[email protected]", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,27 +80,30 @@ const MagisterApi = { | |
) | ||
}) | ||
}, | ||
examInfo: async (year) => { | ||
return new Promise(async (resolve, reject) => { | ||
magisterApiCache['examInfo' + year?.id] ??= | ||
fetchWrapper( | ||
`https://${magisterApiSchoolName}.magister.net/api/aanmeldingen/${year?.id}/examen`, null, 'examInfo' | ||
|
||
exams: { | ||
list: async (year) => { | ||
return new Promise(async (resolve, reject) => { | ||
magisterApiCache['examsList' + year?.id] ??= | ||
fetchWrapper( | ||
`https://${magisterApiSchoolName}.magister.net/api/aanmeldingen/${year?.id}/examens`, null, 'examsList' | ||
) | ||
resolve( | ||
(await magisterApiCache['examsList' + year?.id])?.items || null | ||
) | ||
resolve( | ||
(await magisterApiCache['examInfo' + year?.id]) | ||
) | ||
}) | ||
}, | ||
exams: async (year) => { | ||
return new Promise(async (resolve, reject) => { | ||
magisterApiCache['exams' + year?.id] ??= | ||
fetchWrapper( | ||
`https://${magisterApiSchoolName}.magister.net/api/aanmeldingen/${year?.id}/examens`, null, 'exams' | ||
}) | ||
}, | ||
info: async (year) => { | ||
return new Promise(async (resolve, reject) => { | ||
magisterApiCache['examsInfo' + year?.id] ??= | ||
fetchWrapper( | ||
`https://${magisterApiSchoolName}.magister.net/api/aanmeldingen/${year?.id}/examen`, null, 'examsInfo', true | ||
) | ||
resolve( | ||
(await magisterApiCache['examsInfo' + year?.id]) || {} | ||
) | ||
resolve( | ||
(await magisterApiCache['exams' + year?.id])?.items | ||
) | ||
}) | ||
}) | ||
} | ||
}, | ||
events: async (start = gatherStart, end = gatherEnd) => { | ||
return new Promise(async (resolve, reject) => { | ||
|
@@ -226,7 +229,7 @@ const MagisterApi = { | |
* @param {Object} options | ||
* @returns {Promise<Object>} | ||
*/ | ||
async function fetchWrapper(url, options, identifier = 'unknown') { | ||
async function fetchWrapper(url, options, identifier = 'unknown', quiet = false) { | ||
const calledAt = new Date() | ||
|
||
const promiseReq = new Promise(async (resolve, reject) => { | ||
|
@@ -257,7 +260,7 @@ async function fetchWrapper(url, options, identifier = 'unknown') { | |
} | ||
|
||
// Reject when ratelimit is hit | ||
if (res1.status === 429) { | ||
if (res1.status === 429 && !quiet) { | ||
notify('snackbar', `Verzoeksquotum overschreden\nWacht even, vernieuw de pagina en probeer het opnieuw`) | ||
return resolve({}) | ||
} | ||
|
@@ -289,22 +292,24 @@ async function fetchWrapper(url, options, identifier = 'unknown') { | |
} | ||
|
||
// Reject when ratelimit is hit | ||
if (res2.status === 429) { | ||
if (res2.status === 429 && !quiet) { | ||
notify('snackbar', `Verzoeksquotum overschreden\nWacht even, vernieuw de pagina en probeer het opnieuw`) | ||
return resolve({}) | ||
} | ||
|
||
// Handle other errors | ||
notify( | ||
'snackbar', | ||
`Fout ${res2.status}. Druk op Ctrl + Shift + J en stuur me een screenshot!`, | ||
[ | ||
{ innerText: "E-mail", href: `mailto:[email protected]` }, | ||
{ innerText: "Discord", href: `https://discord.gg/2rP7pfeAKf` } | ||
], | ||
120000 | ||
) | ||
console.log(`Het zou me erg helpen als je een screenshot of kopie van de volgende informatie doorstuurt via e-mail ([email protected]) of Discord (https://discord.gg/2rP7pfeAKf) 💚`) | ||
if (!quiet) { | ||
notify( | ||
'snackbar', | ||
`Fout ${res2.status}. Druk op Ctrl + Shift + J en stuur me een screenshot!`, | ||
[ | ||
{ innerText: "E-mail", href: `mailto:[email protected]` }, | ||
{ innerText: "Discord", href: `https://discord.gg/2rP7pfeAKf` } | ||
], | ||
120000 | ||
) | ||
console.log(`Het zou me erg helpen als je een screenshot of kopie van de volgende informatie doorstuurt via e-mail ([email protected]) of Discord (https://discord.gg/2rP7pfeAKf) 💚`) | ||
} | ||
console.error(`APIRQ: ${res2.status}\n\nurl: ${url}\nuserId: ${magisterApiUserId}\nuserToken.length: ${magisterApiUserToken?.length} (@ ${identifier})`) | ||
return resolve({}) | ||
}) | ||
|
@@ -317,16 +322,18 @@ async function fetchWrapper(url, options, identifier = 'unknown') { | |
}) | ||
]) | ||
.catch(err => { | ||
notify( | ||
'snackbar', | ||
`Er is iets misgegaan. Druk op Ctrl + Shift + J en stuur me een screenshot!`, | ||
[ | ||
{ innerText: "e-mail", href: `mailto:[email protected]` }, | ||
{ innerText: "Discord", href: `https://discord.gg/2rP7pfeAKf` } | ||
], | ||
120000 | ||
) | ||
console.log(`Het zou me erg helpen als je een screenshot of kopie van de volgende informatie doorstuurt via e-mail ([email protected]) of Discord (https://discord.gg/2rP7pfeAKf) 💚`) | ||
if (!quiet) { | ||
notify( | ||
'snackbar', | ||
`Er is iets misgegaan. Druk op Ctrl + Shift + J en stuur me een screenshot!`, | ||
[ | ||
{ innerText: "e-mail", href: `mailto:[email protected]` }, | ||
{ innerText: "Discord", href: `https://discord.gg/2rP7pfeAKf` } | ||
], | ||
120000 | ||
) | ||
console.log(`Het zou me erg helpen als je een screenshot of kopie van de volgende informatie doorstuurt via e-mail ([email protected]) of Discord (https://discord.gg/2rP7pfeAKf) 💚`) | ||
} | ||
console.error(`APIRQ: ${err}\n\nurl: ${url}\nuserId: ${magisterApiUserId}\nuserToken.length: ${magisterApiUserToken?.length} (@ ${identifier})`) | ||
return ({}) | ||
}) | ||
|
Oops, something went wrong.