Skip to content

Commit ebbcd5b

Browse files
committed
3.15.2-beta.3
1 parent 06cd1e4 commit ebbcd5b

19 files changed

Lines changed: 381 additions & 108 deletions

File tree

.github/FUNDING.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
custom: ["paypal.me/QkeleQ10"]

manifest-firefox.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 3,
33
"name": "__MSG_appName__",
44
"description": "__MSG_appDesc__",
5-
"version": "3.15.2.2",
5+
"version": "3.15.2.3",
66
"default_locale": "nl",
77
"icons": {
88
"16": "icons/icon@16px.png",

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 3,
33
"name": "__MSG_appName__",
44
"description": "__MSG_appDesc__",
5-
"version": "3.15.2.2",
5+
"version": "3.15.2.3",
66
"default_locale": "nl",
77
"icons": {
88
"16": "icons/icon@16px.png",

popup/src/components/About.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ function openInNewTab(url) {
6565
<button class="button tonal" @click="openInNewTab('https://discord.gg/2rP7pfeAKf')">
6666
<Icon>forum</Icon><span>Discord</span>
6767
</button>
68-
<button class="button tonal" @click="openInNewTab('https://paypal.me/QkeleQ10')">
68+
<!-- <button class="button tonal" @click="openInNewTab('https://paypal.me/QkeleQ10')">
6969
<Icon>volunteer_activism</Icon><span>PayPal</span>
70-
</button>
70+
</button> -->
7171
<button class="button tonal" @click="disclaimerOpen = true">
7272
<Icon>shield_locked</Icon><span>Privacybeleid</span>
7373
</button>

src/globals.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ interface Date {
4444
getFormattedTime(): string;
4545

4646
addDays(days: number): Date;
47+
previousMonday(): Date;
4748

4849
isToday(offset?: number): boolean;
4950
isTomorrow(offset?: number): boolean;

src/scripts/api.js

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class MagisterApi {
1616

1717
this.updateApiCredentials();
1818

19-
this.permissions = await this.updateApiPermissions();
19+
await this.updateAccountInfo();
2020
this.gatherStart = dates.gatherStart;
2121
this.gatherEarlyStart = dates.gatherEarlyStart;
2222
this.gatherEnd = dates.gatherEnd;
@@ -47,10 +47,15 @@ class MagisterApi {
4747
}
4848
}
4949

50-
async updateApiPermissions() {
50+
async updateAccountInfo() {
5151
return new Promise(async (resolve) => {
52-
this.permissions = (await new MagisterApiRequestAccount().get())?.Groep?.[0]?.Privileges?.filter(p => p.AccessType.includes('Read')).map(p => p.Naam);
53-
resolve(this.permissions);
52+
const account = await this.accountInfo();
53+
this.permissions = account?.Groep?.[0]?.Privileges?.filter(p => p.AccessType.includes('Read')).map(p => p.Naam);
54+
this.uuid = account?.UuId;
55+
56+
const calendarFeatures = await this.getCalendarFeatures();
57+
this.calendarFeatures = calendarFeatures || {};
58+
resolve({ permissions: this.permissions, uuid: this.uuid, calendarFeatures: this.calendarFeatures });
5459
});
5560
}
5661

@@ -111,6 +116,18 @@ class MagisterApi {
111116
return new MagisterApiRequestKwtRegistration(id).delete();
112117
}
113118

119+
getCalendarFeatures() {
120+
return new MagisterApiRequestCalendarFeatures().get();
121+
}
122+
123+
additionalAppointments(start = dates.now, end = dates.now) {
124+
return new MagisterApiRequestAdditionalAppointments(start, end).get();
125+
}
126+
127+
enrollAdditionalAppointment(path) {
128+
return new MagisterApiRequestEnrollAdditionalAppointment(path).post();
129+
}
130+
114131
gradesRecent(size = 25) {
115132
return new MagisterApiRequestGradesRecent(size).get();
116133
}
@@ -155,6 +172,7 @@ class MagisterApi {
155172
class MagisterApiRequest {
156173
identifier;
157174
path;
175+
href;
158176

159177
constructor() {
160178
}
@@ -165,13 +183,13 @@ class MagisterApiRequest {
165183

166184
if (magisterApi.useSampleData && this.sample) {
167185
return Promise.resolve(this.sample);
168-
} else if (!this.identifier || !this.path) {
169-
return Promise.reject();
186+
} else if (!this.identifier || (!this.path && !this.href)) {
187+
return Promise.reject("Invalid API request: no identifier or path/href specified.");
170188
} else if (magisterApi.cache[this.identifier] && !magisterApi.cache[this.identifier].then) {
171189
return Promise.resolve(magisterApi.cache[this.identifier]);
172190
} else {
173191
return this.#fetchWrapper(
174-
`https://${magisterApi.schoolName}.magister.net/${this.path}`,
192+
(this.href || `https://${magisterApi.schoolName}.magister.net/${this.path}`),
175193
options
176194
);
177195
}
@@ -182,7 +200,7 @@ class MagisterApiRequest {
182200
if (!window.location.pathname.includes('magister')) reject();
183201

184202
let res = await fetch(
185-
`https://${magisterApi.schoolName}.magister.net/${this.path}`.replace(/(\$USERID)/gi, magisterApi.userId),
203+
(this.href || `https://${magisterApi.schoolName}.magister.net/${this.path}`).replace(/(\$USERID)/gi, magisterApi.userId).replace(/(\$UUID)/gi, magisterApi.uuid),
186204
{
187205
method: 'PUT',
188206
body: JSON.stringify(body),
@@ -205,7 +223,7 @@ class MagisterApiRequest {
205223
if (!window.location.pathname.includes('magister')) reject();
206224

207225
let res = await fetch(
208-
`https://${magisterApi.schoolName}.magister.net/${this.path}`.replace(/(\$USERID)/gi, magisterApi.userId),
226+
(this.href || `https://${magisterApi.schoolName}.magister.net/${this.path}`).replace(/(\$USERID)/gi, magisterApi.userId).replace(/(\$UUID)/gi, magisterApi.uuid),
209227
{
210228
method: 'POST',
211229
body: JSON.stringify(body),
@@ -228,7 +246,7 @@ class MagisterApiRequest {
228246
if (!window.location.pathname.includes('magister')) reject();
229247

230248
let res = await fetch(
231-
`https://${magisterApi.schoolName}.magister.net/${this.path}`.replace(/(\$USERID)/gi, magisterApi.userId),
249+
(this.href || `https://${magisterApi.schoolName}.magister.net/${this.path}`).replace(/(\$USERID)/gi, magisterApi.userId).replace(/(\$UUID)/gi, magisterApi.uuid),
232250
{
233251
method: 'DELETE',
234252
body: JSON.stringify(body),
@@ -286,7 +304,7 @@ class MagisterApiRequest {
286304
}
287305

288306
try {
289-
let res = await fetch(url.replace(/(\$USERID)/gi, magisterApi.userId), {
307+
let res = await fetch(url.replace(/(\$USERID)/gi, magisterApi.userId).replace(/(\$UUID)/gi, magisterApi.uuid), {
290308
headers: {
291309
Authorization: magisterApi.userToken,
292310
'X-Request-Source': 'study-tools'
@@ -411,6 +429,30 @@ class MagisterApiRequestKwtRegistration extends MagisterApiRequest {
411429
}
412430
}
413431

432+
class MagisterApiRequestCalendarFeatures extends MagisterApiRequest {
433+
constructor(start, end) {
434+
super();
435+
this.identifier = `calendarFeatures`;
436+
this.href = `https://calendar.magister.net/api/user/$UUID/features`;
437+
}
438+
}
439+
440+
class MagisterApiRequestAdditionalAppointments extends MagisterApiRequest {
441+
constructor(start, end) {
442+
super();
443+
this.identifier = `additionalAppointments${start?.toISOString()}${end?.toISOString()}`;
444+
this.href = `https://calendar.magister.net/api/user/$UUID/additional-appointments?start=${start?.toISOString().substring(0, 19)}%2B00:00&end=${end?.toISOString().substring(0, 19)}%2B00:00`;
445+
}
446+
}
447+
448+
class MagisterApiRequestEnrollAdditionalAppointment extends MagisterApiRequest {
449+
constructor(path) {
450+
super();
451+
this.identifier = `additionalAppointmentsEnroll${path}`;
452+
this.href = `https://calendar.magister.net/${path}`;
453+
}
454+
}
455+
414456
class MagisterApiRequestGradesRecent extends MagisterApiRequest {
415457
constructor(size = 25) {
416458
super();

src/scripts/gamification.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ async function checkWrapped() {
2727
let examInfo = {}
2828
let recentGrades = []
2929

30-
await magisterApi.updateApiPermissions();
30+
await magisterApi.updateAccountInfo();
3131

3232
if (magisterApi.permissions?.includes('ExamenTijdvak'))
3333
try {
@@ -164,7 +164,7 @@ async function constructWrapped(lastYearOnly) {
164164
"Study Tools Wrapped is nog gloednieuw. De hele ervaring is veel te snel in elkaar geflanst, met relatief weinig tests en input.\nFeedback (in de vorm van suggesties en probleemrapporten) is daarom meer dan welkom!\n\nNeem contact met me op in de Discord-server. En deel ook vooral screenshots van jouw Wrapped of klets wat met de andere leden!",
165165
[
166166
{ innerText: "Discord", onclick: `window.open('https://discord.gg/2rP7pfeAKf')` },
167-
{ innerText: "PayPal", onclick: `window.open('https://paypal.me/QkeleQ10')` }
167+
// { innerText: "PayPal", onclick: `window.open('https://paypal.me/QkeleQ10')` }
168168
], null, { index: 3, length: 3 })
169169
})
170170

0 commit comments

Comments
 (0)