ChildishGiant / Channel 4 Spacebar play/pause

// ==UserScript==
// @name         Channel 4 Spacebar play/pause
// @namespace    childishgiant.channel4
// @version      0.1
// @description  Makes play and pause with spacebar work on the Channel 4 on demand service.
// @author       ChildishGiant (allie@cloverleaf.app)
// @match        https://www.channel4.com/programmes/*/on-demand/*
// @grant        none
// @copyright 2023, ChildishGiant (https://openuserjs.org/users/ChildishGiant)
// @license 0BSD
// ==/UserScript==

function toggle (e) (e) {
    if (e.keyCode == 32) {
        try {
        document.querySelector('.controls-container__control-button--play').click()
        }
        catch (TypeError) {
            document.querySelector('.controls-container__control-button--pause').click()
        }
    }
}

(function () {
    'use strict';
    document.body.onkeyup = toggle
    document.querySelector(".vod-player").onkeyup = toggle
})();