aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/googleclassroom/webview.js
blob: 5035417f4405c728c534e1d33c8b05067b5799d1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
module.exports = Ferdium => {
  // if the user is on googleclassroom landing page, go to the login page.
  if (
    location.hostname == 'edu.google.com' &&
    location.href.includes('workspace-for-education/classroom/')
  ) {
    location.href =
      'https://accounts.google.com/AccountChooser?continue=https://classroom.google.com/u/0/';
  }

  const getMessages = () => {
    let homework = 0;
    const upcomingAssignment = document.querySelectorAll('.hrUpcomingAssignmentGroup');
    if (upcomingAssignment.length > 0) {
      let i;
      for (i = 0; i < upcomingAssignment.length; i++) {
        homework += upcomingAssignment[i].childElementCount;
      }
    }
    Ferdium.setBadge(homework);
  };

  Ferdium.loop(getMessages);
};