#EmacsConf backstage: Automatically join BigBlueButton web conferences using Tampermonkey

| emacs, emacsconf

[2023-10-22 Sun] Added IRC script

During EmacsConf, we join BigBlueButton webconferences for live presentations and Q&A sessions so that the speakers and the host can be on stream. I wanted to reduce the number of manual steps needed to join the web conference, since any clicks or keystrokes would need to be done via a VNC connection. I used Tampermonkey to write a script to join BigBlueButton and set things up the way we want to.

I don't have the Tampermonkey installation and setup automated with Ansible yet, but here's what I did for each track:

  1. Install the Tampermonkey extension by going to https://addons.mozilla.org/en-US/firefox/addon/tampermonkey/ .
  2. Install the script by clicking on the Tampermonkey extension, choosing Install New Script, and pasting in the following:

       // ==UserScript==
       // @name         Emacsconf BBB setup
       // @namespace    https://emacsconf.org/
       // @version      0.1
       // @description  Join BBB and set things up
       // @author       You
       // @match        https://bbb.emacsverse.org/*
       // @icon         https://www.google.com/s2/favicons?sz=64&domain=emacsverse.org
       // @grant        none
       // ==/UserScript==
       (
           async function() {
               'use strict';
               const NAME = 'emacsconf';
               async function waitUntil(conditionFunc, interval=500, timeout=null) {
                   let initResult = conditionFunc();
                   if (initResult) return initResult;
                   return new Promise((resolve, reject) => {
                       let timeSoFar = 0;
                       let timer = setInterval(() => {
                           let result = conditionFunc();
                           if (result) {
                               clearInterval(timer);
                               resolve(result);
                           }
                           timeSoFar += interval;
                           if (timeout && timeSoFar > timeout) {
                               clearInterval(timer);
                               reject();
                           }
                       }, interval);
                   });
               }
               if (document.querySelector('input.join-form')) {
                   document.querySelector('input.join-form').value = NAME;
                   document.querySelector('#room-join').click();
                   return;
               }
               await waitUntil(() => document.querySelector('.icon-bbb-listen')).then((e) => e.closest('button').click());
               await waitUntil(() => document.querySelector('.icon-bbb-user')).then((e) => e.closest('button').click());
       })();
    

    Press Ctrl+s to save.

  3. Add this script to join the IRC channel:

       // ==UserScript==
       // @name         Connect to EmacsConf chat automatically
       // @namespace    https://emacsconf.org/
       // @version      0.1
       // @description  try to take over the world!
       // @author       You
       // @match        https://chat.emacsconf.org/*
       // @icon         https://www.google.com/s2/favicons?sz=64&domain=emacsconf.org
       // @grant        none
       // ==/UserScript==
    
       (function() {
           'use strict';
           setTimeout(() => {
               if (document.querySelector('.connect-row')) {
                   document.querySelector('.connect-row').closest('form').querySelector('button').click();
               }
           }, 1000);
       })();
    
  4. Join an BBB meeting. Check the address bar to see if autoplay is disabled (crossed-out autoplay icon). If it is, click on it and change Block audio to Allow audio and video.

Now I can use this Ansible template for a shell script to connect to the BBB session (roles/obs/templates/bbb):

#!/bin/bash
# Open the Big Blue Button room using the backstage link
# 

# Kill the background music if playing
if screen -list | grep -q background; then
    screen -S background -X quit
fi

# Update the overlay
SLUG=$1
overlay $SLUG
killall -s TERM firefox-esr
firefox https://media.emacsconf.org//backstage/assets/redirects/open/bbb-$SLUG.html &
sleep 5
xdotool search --class firefox windowactivate --sync
xdotool key Return
xdotool key F11
wait

The overlay is handled by this script (roles/obs/templates/overlay):

#!/bin/bash
# 

SLUG=$(echo "$1" | perl -ne 'if (/emacsconf-[0-9]*-(.*?)--/) { print $1; } else { print; }')

if [[ -f /assets/overlays/$SLUG-other.svg.png ]]; then
    echo "Found other overlay for $SLUG, copying"
    cp /assets/overlays/$SLUG-other.svg.png ~/other.png
elif [[ -f /assets/overlays/$SLUG-video.svg.png ]]; then
    echo "Found video overlay for $SLUG, copying"
    cp /assets/overlays/$SLUG-video.svg.png ~/other.png
else
    echo "Could not find /assets/overlays/$SLUG-other.svg.png, please override ~/other.png manually"
    cp /assets/overlays/blank-other.svg.png ~/other.png
fi
if [[ -f /assets/overlays/$SLUG-video.svg.png ]]; then
    echo "Found video overlay for $SLUG, copying"
    cp /assets/overlays/$SLUG-video.svg.png ~/video.png
else
    echo "Could not find /assets/overlays/$SLUG-video.svg.png, override ~/video.png manually"
    cp /assets/overlays/blank-video.svg.png ~/video.png
fi

The result: I can run bbb uni and it'll automatically join the Q&A session for the uni talk in listen-only mode and with the user list hidden.

You can comment with Disqus or you can e-mail me at sacha@sachachua.com.