Recently online classes have started for my daughter. She’s in UKG, and when she was in LKG, she used to have online classes start at 7 p.m. The situation changed in UKG however, and the classes were scheduled to start at 6 p.m. That’s a minor change, you might say. Well, it started becoming a problem with my clinical practise. I usually wind up my consultation by 6.15 pm. Nowadays, with lockdown having been lifted, the roads are overflowing with people, and the traffic snarls at Sreekariyam junction have started becoming a bother. All this means that by the time I get home, it’s usually 7 pm, and my daughter’s classes would already have gotten almost over.
My parents do help with classes. But they are hard pressed with managing three kids at home at the same time. My kid does not have issues following classes, but is unable to open the browser and open the page of her school’s class. She is learning fast however. The problem is to open the site, login in entering some details, opening some links (all rather mechanical), and also in knowing what was taught in the class.
Most people consider me a geek. So I dived into my geekish repo, and came out with a solution.. Automatise the whole process. So I solved the issue of opening the page for online class for my daughter, logging into the class, automatically refreshing the page checking for Google Meet links, and opening it once the link appears. So all my daughter needs to do, is to sit near the computer at the time of the class. And she will be reminded to do that by Amazon Alexa, a nifty device which announces that her class is about to start.
The rest of my post is rather technical, so if you are interested in that sort of thing, and to do it yourself, read on..
Task No: 1 – Starting Chrome browser at the scheduled time, to the school’s page.
Solution:
I crafted a small script to:
- Close all existing Chrome browser windows (Kids might have been watching Hotstar or Netflix)
- Open Chrome at the specific page of Online Class, maximize the browser to avoid distractions.
Script:
#!/bin/sh
/usr/bin/killall chrome
/opt/google/chrome/chrome --start-maximized --app=https://nlp.nexterp.in/nlp/nlp/v1/student/student-dashboard#/
The first command kills all existing Chrome browser windows. The second one opens the browser in app mode, which is a distraction free mode, with just one page open, minus all toolbars.
Task No: 2 – Scheduling this script to run at the right time.
I need the program which opens the browser
Linux of course has a nifty scheduler called cron. The following cron job does the task of running my script on every Monday, Wednesday and Friday, 10 minutes before my daughter’s class:
50 17 * * MON,WED,SAT /home/joel/scripts/activateonlineclass.sh
Task No: 3 – Logging into the site, entering the username, password and school code
My parents found it difficult to type my complex password each time. They also found it hard to use the password manager extension I had. So I needed to automatize the typing of these details and logging in to the page. I installed Tampermonkey extension for Chrome. This can automatize tasks if you give it instructions in Javascript. So the following is my script to fill in the username, password and school code, and then to emulate a click on a button. So the program would do all that.
// ==UserScript==
// @name Holy Angels Helper
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Automatise online classes for Holy Angels School
// @author Dr Joel G Mathew, aka Droidzone
// @match https://nlp.nexterp.in/nlp/nlp/*
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @require https://code.jquery.com/jquery-3.3.1.min.js
// @grant none
// ==/UserScript==
(function () {
'use strict';
console.log("Loaded script for NLP");
waitForKeyElements("input.md-input", actionFunction);
function actionFunction() {
console.log("In actionFunction");
$("#input_0").val("1234"); //The roll number
$("#input_2").val("mypassword"); //Add your password here
$("#input_4").val("hais"); //School code for Holy Angels
$('button[name="btnSignIn"]').click();
}
Done.. Now when Chrome is automatically opened by Linux cron, this script would kick in, and login to the page after filling all details in the form.
Task No: 3 – Automatically reload the page to get the Google Meet link
The programmers at Next NLP learning platform have made it very difficult to join online class. They generate a dynamic link for Google Meet that is opened on clicking an element on the page that will appear on the page only if we keep refreshing the page. So to automatise this reloading, I added another Tampermonkey script:
// ==UserScript==
// @name Auto refresh Holy Angels
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Auto refresh Holy Angels Page every 10 sec
// @author Dr Joel G Mathew, aka Droidzone
// @match https://nlp.nexterp.in/nlp/nlp/v1/student/student-dashboard*
// ==/UserScript==
(function() {
'use strict';
console.log("Loaded Auto refresh script")
setTimeout(function(){ location.reload(); }, 10*1000);
})();
Task No: 3 – Automatically record the classes so that I can revise what she learnt
For this, I used OBS Studio, and started it automatically at the scheduled time using the following cron job:
Download OBS Studio web socket from here
Joel G Mathew, known in tech circles by the pseudonym Droidzone, is an opensource and programming enthusiast.
He is a full stack developer, whose favorite languages are currently Python and Vue.js. He is also fluent in Javascript, Flutter/Dart, Perl, PHP, SQL, C and bash shell scripting. He loves Linux, and can often be found tinkering with linux kernel code, and source code for GNU applications. He used to be an active developer on XDA forums, and his tinkered ROMS used to be very popular in the early 2000s.
His favorite pastime is grappling with GNU compilers, discovering newer Linux secrets, writing scripts, hacking roms, and programs (nothing illegal), reading, blogging. and testing out the latest gadgets.
When away from the tech world, Dr Joel G. Mathew is a practising ENT Surgeon, busy with surgeries and clinical practise.