Skip to content

Commit 0868765

Browse files
authored
feat(Google Calendar): display event name (#10337)
1 parent 1b0796b commit 0868765

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

websites/G/Google Calendar/Google Calendar.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@
7171
"description": "Displayed when the user is searching for an event.",
7272
"message": "Searching the event:"
7373
},
74+
"googlecalendar.viewingAnEvent": {
75+
"description": "Displayed when the user is viewing an event.",
76+
"message": "Viewing an event"
77+
},
7478
"googlecalendar.viewingCalendar": {
7579
"description": "Displayed when the user is viewing a calendar.",
7680
"message": "Viewing the calendar"

websites/G/Google Calendar/metadata.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"url": "calendar.google.com",
2727
"regExp": "^https?[:][/][/]calendar[.]google[.]com[/]",
28-
"version": "1.4.1",
28+
"version": "1.4.2",
2929
"logo": "https://cdn.rcd.gg/PreMiD/websites/G/Google%20Calendar/assets/logo.png",
3030
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/G/Google%20Calendar/assets/thumbnail.png",
3131
"color": "#4285F4",
@@ -41,6 +41,12 @@
4141
{
4242
"id": "lang",
4343
"multiLanguage": true
44+
},
45+
{
46+
"id": "privacy",
47+
"title": "Privacy Mode",
48+
"icon": "fad fa-user-secret",
49+
"value": true
4450
}
4551
]
4652
}

websites/G/Google Calendar/presence.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ async function getStrings() {
1717
customDays: 'googlecalendar.customDays',
1818
customizingCalendar: 'googlecalendar.customizingCalendar',
1919
daySchedule: 'googlecalendar.daySchedule',
20+
viewingAnEvent: 'googlecalendar.viewingAnEvent',
2021
editingAnEvent: 'googlecalendar.editingAnEvent',
2122
exportingCalendar: 'googlecalendar.exportingCalendar',
2223
generalSettings: 'googlecalendar.generalSettings',
@@ -36,9 +37,11 @@ presence.on('UpdateData', async () => {
3637
largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/G/Google%20Calendar/assets/logo.png',
3738
startTimestamp: browsingTimestamp,
3839
}
40+
const privacy = await presence.getSetting<boolean>('privacy')
3941
const strings = await getStrings()
4042
// eslint-disable-next-line regexp/no-unused-capturing-group
4143
const date = document.title?.replace(/Google[\xA0 ](Calendar|Agenda) -/, '')?.replaceAll(',', ' -')?.trim()
44+
const eventDialog = document.querySelector('div[role="dialog"]')
4245

4346
if (document.location.pathname === '/') {
4447
presenceData.details = strings.home
@@ -67,8 +70,13 @@ presence.on('UpdateData', async () => {
6770
presenceData.details = strings.viewingScheduleOf
6871
presenceData.state = strings.customDays
6972
}
73+
else if (eventDialog) {
74+
presenceData.details = strings.viewingAnEvent
75+
presenceData.state = privacy ? '' : eventDialog?.querySelector('span[role="heading"]')?.textContent || ''
76+
}
7077
else if (document.location.pathname.includes('/r/eventedit')) {
7178
presenceData.details = strings.editingAnEvent
79+
presenceData.state = privacy ? '' : document.querySelector<HTMLInputElement>('div[role="main"] input[type="text"]')?.value || ''
7280
}
7381
else if (document.location.pathname.includes('/r/search')) {
7482
presenceData.details = strings.searchingEvent

0 commit comments

Comments
 (0)