Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mast4461/a8e1cb09f19d20de7fc2201a881c4422 to your computer and use it in GitHub Desktop.
Save mast4461/a8e1cb09f19d20de7fc2201a881c4422 to your computer and use it in GitHub Desktop.
Video playback rate hotkeys for Coursera, through Tampermonkey
// ==UserScript==
// @name Coursera playback rate hotkeys
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Add button listeners to + and - keys for changing the video playback rate on Coursera
// @author You
// @match https://www.coursera.org/learn/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Attach event listeners
document.body.addEventListener("keypress", ({key}) => {
switch (key) {
case "-": return document.querySelector("button[aria-label='decrease playback rate']").click();
case "+": return document.querySelector("button[aria-label='increase playback rate']").click();
}
});
// Add text informing about playback rate controls
document.querySelector("style").sheet.insertRule(`.rc-PlayButton:before {
content: "+ and - controls playback rate with TamperMonkey";
font-size: 16pt;
background-color: white;
padding: 5pt;
opacity: 0.8;
border-radius: 5pt;
}`);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment