Google Calendar Add-on to set the block color of events synced by SchoolCal
This Google Calendar Add-on searches your calendar for all events synced by SchoolCal from your myGroton Schedule. You can either opt to use pre-defined block colors to assign a color matching the block to your classes, or you can do your own custom search/color-assignment combination. (For example, search for "Advanced History" and color it "Pale Red".) The color palette is limited by the available event colors in Google Calendar.
Refer to my gist on Google Workspace Add-on publication for general directions on how to administratively publish a Google Workspace Add-on.
This add-on is a Google Workspace Add-on in its GCP app configuration and uses the Google Calendar API (which should be automatically enabled when you configure the GCP project's OAuth scopes).
To ensure that you only edit events created by SchoolCal, you need to specify your SchoolSync.SchoolId in the Script Settings:
- Visit https://go.schoolcal.com as an administrator
- Open your web inspector or developer view (whatever your browser calls it) and look at the network traffic. You're looking for requests to
https://go.schoolcal.co/Jobs/CurrentJobs. In the response to this request, you will see JSON data that starts with yourSchoolId. - Open the script associated with your Google Workspace Add-on (step 1 of "in the browser") and click the Project Settings gear in the left-hand sidebar.
- Add a Script Property with the name
SchoolSync.SchoolIdand the value you determined in step 2.
This script was written in about 15 minutes, and you may need to adjust it to your purposes. The list of color codes and Google Calendar colors is stored in the blocks variable in src/Calendar.ts. You can adjust the patterns and color assignments to suit your need. Note that you will need to quote patterns that include non-alphabetic characters.
const blocks = {
'Red Block': '11',
OR: '6',
YL: '5',
GR: '2',
LB: '7',
DB: '9',
PR: '3'
};The color codes are defined in the Google Calendar documentation (and can be sneaked from the menu-creation at the end of the script as well).
If you want to adjust how the pattern is matched, you will need to edit the snippet that is currently (${code} and therefor matching things like (RD.
This app collects and stores no data.
No license or warranty is provided or granted. Use at your own risk.