Skip to content

Instantly share code, notes, and snippets.

@ewels
Created March 1, 2024 09:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ewels/8815c45f31cf13e6c4305fdd01a2fee0 to your computer and use it in GitHub Desktop.
Save ewels/8815c45f31cf13e6c4305fdd01a2fee0 to your computer and use it in GitHub Desktop.
StreamYard UserScript to add missing hotkeys
// ==UserScript==
// @name StreamYard overlay/music hotkeys
// @namespace https://phil.ewels.co.uk/
// @version 2024-02-29
// @description Add missing hotkeys for StreamYard
// @author Phil Ewels
// @match https://streamyard.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=streamyard.com
// @grant none
// ==/UserScript==
// Edit as appropriate for your music / overlay names
// - NB: All shortcut keys have SHIFT added
// - NB: Take visible text from buttons, then add ` music`
// for background music or ` overlay` for overlays.
const shortcut_keys = [
["M", "Feeding the ducks music"],
["Q", "podcast_start_screen overlay"],
["W", "podcast_overlay overlay"],
["E", "podcast_end_screen overlay"],
];
function findAndClickButton(labelText) {
var buttonElement = document.querySelector('button[aria-label="' + labelText + '"]');
if (!buttonElement) {
alert("Button with label '" + labelText + "' not found.");
return;
} else {
buttonElement.click();
}
}
(function() {
'use strict';
shortcut_keys.forEach(([key, labelText]) => {
document.addEventListener('keydown', function(event) {
if (event.shiftKey && event.key === key) {
findAndClickButton(labelText);
}
});
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment