From 4fc6a9933882378f0cad66827bb79c2124d365e9 Mon Sep 17 00:00:00 2001
From: lehtint6 <teemu.t.lehtinen@aalto.fi>
Date: Thu, 2 Apr 2020 10:45:42 +0300
Subject: [PATCH] Prevent grader of clicking null

---
 content.js | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/content.js b/content.js
index 9ec6ab4..5289a14 100644
--- a/content.js
+++ b/content.js
@@ -598,9 +598,11 @@ let Content = {
       let p = 0;
       ['C4', 'D4', 'D#4', 'C#4', 'E4'].forEach(function (id) {
         let b = doc.getElementById(id);
-        b.click();
-        p += b.classList.contains('last-played') ? 1 : 0;
-        p += doc.querySelectorAll('.last-played').length == 1 ? 1 : 0;
+        if (b) {
+          b.click();
+          p += b.classList.contains('last-played') ? 1 : 0;
+          p += doc.querySelectorAll('.last-played').length == 1 ? 1 : 0;
+        }
       });
       return { points: p };
     },
-- 
GitLab