Created
December 14, 2020 06:29
-
-
Save mast4461/a8e1cb09f19d20de7fc2201a881c4422 to your computer and use it in GitHub Desktop.
Video playback rate hotkeys for Coursera, through Tampermonkey
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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