Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions websites/G/Google Calendar/Google Calendar.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@
"description": "Displayed when the user is searching for an event.",
"message": "Searching the event:"
},
"googlecalendar.viewingAnEvent": {
"description": "Displayed when the user is viewing an event.",
"message": "Viewing an event"
},
"googlecalendar.viewingCalendar": {
"description": "Displayed when the user is viewing a calendar.",
"message": "Viewing the calendar"
Expand Down
8 changes: 7 additions & 1 deletion websites/G/Google Calendar/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"url": "calendar.google.com",
"regExp": "^https?[:][/][/]calendar[.]google[.]com[/]",
"version": "1.4.1",
"version": "1.4.2",
"logo": "https://cdn.rcd.gg/PreMiD/websites/G/Google%20Calendar/assets/logo.png",
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/G/Google%20Calendar/assets/thumbnail.png",
"color": "#4285F4",
Expand All @@ -41,6 +41,12 @@
{
"id": "lang",
"multiLanguage": true
},
{
"id": "privacy",
"title": "Privacy Mode",
"icon": "fad fa-user-secret",
"value": true
}
]
}
8 changes: 8 additions & 0 deletions websites/G/Google Calendar/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ async function getStrings() {
customDays: 'googlecalendar.customDays',
customizingCalendar: 'googlecalendar.customizingCalendar',
daySchedule: 'googlecalendar.daySchedule',
viewingAnEvent: 'googlecalendar.viewingAnEvent',
editingAnEvent: 'googlecalendar.editingAnEvent',
exportingCalendar: 'googlecalendar.exportingCalendar',
generalSettings: 'googlecalendar.generalSettings',
Expand All @@ -36,9 +37,11 @@ presence.on('UpdateData', async () => {
largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/G/Google%20Calendar/assets/logo.png',
startTimestamp: browsingTimestamp,
}
const privacy = await presence.getSetting<boolean>('privacy')
const strings = await getStrings()
// eslint-disable-next-line regexp/no-unused-capturing-group
const date = document.title?.replace(/Google[\xA0 ](Calendar|Agenda) -/, '')?.replaceAll(',', ' -')?.trim()
const eventDialog = document.querySelector('div[role="dialog"]')

if (document.location.pathname === '/') {
presenceData.details = strings.home
Expand Down Expand Up @@ -67,8 +70,13 @@ presence.on('UpdateData', async () => {
presenceData.details = strings.viewingScheduleOf
presenceData.state = strings.customDays
}
else if (eventDialog) {
presenceData.details = strings.viewingAnEvent
presenceData.state = privacy ? '' : eventDialog?.querySelector('span[role="heading"]')?.textContent || ''
}
else if (document.location.pathname.includes('/r/eventedit')) {
presenceData.details = strings.editingAnEvent
presenceData.state = privacy ? '' : document.querySelector<HTMLInputElement>('div[role="main"] input[type="text"]')?.value || ''
}
else if (document.location.pathname.includes('/r/search')) {
presenceData.details = strings.searchingEvent
Expand Down
Loading