Skip to content

Instantly share code, notes, and snippets.

@fullo
Forked from rothgar/streamyard-tampermonkey.js
Last active November 5, 2020 23:56
Show Gist options
  • Save fullo/7db1046225b0f14374342ccad493b881 to your computer and use it in GitHub Desktop.
Save fullo/7db1046225b0f14374342ccad493b881 to your computer and use it in GitHub Desktop.
Streamyard Keyboard Shortcuts
// ==UserScript==
// @name Streamyard Keyboard Shortcuts
// @namespace http://streamyard.com
// @version 0.1
// @description Simple keyboard shortcuts for streamyard
// @author justinleegarrison@gmail.com
// @author ffullone@gmail.com
// @match https://streamyard.com/*
// @grant none
// @run-at document-end
// ==/UserScript==
(function() {
'use strict';
var keyMap = {17: false, 18: false }; // ctrl+alt+KEY
document.addEventListener('keydown', function(e) {
if (e.keyCode in keyMap) {
keyMap[e.keyCode] = true;
}
console.log(e);
if ( e.key == "1" && keyMap[17] && keyMap[18]) {
var unmuteButton = document.querySelector('[aria-label="Unmute microphone"]');
var muteButton = document.querySelector('[aria-label="Mute microphone"]');
if (unmuteButton !== null) {
unmuteButton.click();
} else {
muteButton.click();
}
} else if (e.key == "2" && keyMap[17] && keyMap[18]) {
var faceUnmuteButton = document.querySelector('[aria-label="turn on camera"]');
var faceMuteButton = document.querySelector('[aria-label="turn off camera"]');
if (faceUnmuteButton !== null) {
faceUnmuteButton.click();
} else {
faceMuteButton.click();
}
} else if (e.key == "3" && keyMap[17] && keyMap[18]) {
var streamUnmuteButtons = document.querySelectorAll('[aria-label="Add to stream"]');
var streamMuteButtons = document.querySelectorAll('[aria-label="Remove from stream"]');
if (streamUnmuteButtons !== null) {
var streamUnmuteButton = streamUnmuteButtons.forEach(btn => btn.click());
}
if (streamMuteButtons !== null) {
var streamMuteButton = streamMuteButtons.forEach(btn => btn.click());
}
} else if (e.key == "4" && keyMap[17] && keyMap[18]) {
var chatButton = document.getElementById("broadcast-aside-tab-chat");
if (chatButton !== null) {
chatButton.click();
}
} else if (e.key == "6" && keyMap[17] && keyMap[18]) {
var brandButton = document.getElementById("broadcast-aside-tab-brand");
if (brandButton !== null) {
brandButton.click();
}
} else if (e.key == "7" && keyMap[17] && keyMap[18]) {
var soloLayout = document.querySelector('[aria-label="Solo layout. The host camera fills all the space. If no host camera, the first guest that was added is used."]');
if (soloLayout !== null) {
soloLayout.click();
}
} else if (e.key == "8" && keyMap[17] && keyMap[18]) {
var thinLayout = document.querySelector('[aria-label="Thin layout. All cameras are visible and squished to fill up all the space."]');
if (thinLayout !== null) {
thinLayout.click();
}
} else if (e.key == "9" && keyMap[17] && keyMap[18]) {
var groupLayout = document.querySelector('[aria-label="Group layout. All cameras are visible and spaced out."]');
if (groupLayout !== null) {
groupLayout.click();
}
} else if (e.key == "0" && keyMap[17] && keyMap[18]) {
var smallLayout = document.querySelector('[aria-label="Small screen layout. One camera and the shared screen are visible. If no screen, it behaves like the leader layout."]');
if (smallLayout !== null) {
smallLayout.click();
}
} else if (e.key == "." && keyMap[17] && keyMap[18]) {
var leaderLayout = document.querySelector('[aria-label="Leader layout. All cameras are visible. One is larger than the others."]');
if (leaderLayout !== null) {
leaderLayout.click();
}
}else if (e.key == "+" && keyMap[17] && keyMap[18]) {
var largeLayout = document.querySelector('[aria-label="Large screen layout. The shared screen is large, all cameras are visible but small. If no screen, it behaves like the group layout."]');
if (largeLayout !== null) {
largeLayout.click();
}
} else if (e.key == "-" && keyMap[17] && keyMap[18]) {
var fullLayout = document.querySelector('[aria-label="Full screen layout. Only the shared screen is visible. If no screen, it behaves like the group layout."]');
if (fullLayout !== null) {
fullLayout.click();
}
}
}, false);
document.addEventListener('keyup', (e) => {
if (e.keyCode in keyMap) {
keyMap[e.keyCode] = false;
}
});
})();
@fullo
Copy link
Author

fullo commented Nov 5, 2020

now is possible to add or remove from the stream all the user at once with "s"

@fullo
Copy link
Author

fullo commented Nov 5, 2020

CTRL+ALT+KEY as shortcut

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment