Created
November 17, 2022 15:54
-
-
Save seb3point0/1427a76723173c4404c757c4fd3714b2 to your computer and use it in GitHub Desktop.
Custom Streamyard automations
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
(function (d) { | |
const music_button = '#broadcast-aside-content-brand [aria-label="Interoperate music"]', | |
video_button = '#broadcast-aside-content-brand [aria-label="Intro overlay"]', | |
wait_screen_button = '#broadcast-aside-content-brand [aria-label="Wait Screen overlay"]', | |
ticker_banner = '#broadcast-aside-content-banners ul li:nth-child(1) button', | |
twitter_banner = '#broadcast-aside-content-banners ul li:nth-child(2) button', | |
subscribe_banner = '#broadcast-aside-content-banners ul li:nth-child(3) button', | |
go_live = 'div[class*="Header__Right"] div[class*="Status__Wrap"] div:last-child button', | |
go_live_activate = 'div[class*="GoLiveOverlay"] h4~div:last-child button:last-child', | |
cropped_layout = 'div[class*="Studio__Layout"] button[aria-label*="Thin layout"]', | |
solo_host = 'div[class*="Cards__Wrap"] > span[class*="Tooltip__StyledSpan"]:nth-child(1) button[aria-label="Solo layout"]', | |
solo_guest = 'div[class*="Cards__Wrap"] > span[class*="Tooltip__StyledSpan"]:nth-child(2) button[aria-label="Solo layout"]', | |
mute_host = 'div[class*="Cards__Wrap"] > span[class*="Tooltip__StyledSpan"]:nth-child(1) button[aria-label="Mute mic"]', | |
unmute_host = 'div[class*="Cards__Wrap"] > span[class*="Tooltip__StyledSpan"]:nth-child(1) button[aria-label="Unmute mic"]', | |
mute_guest = 'div[class*="Cards__Wrap"] > span[class*="Tooltip__StyledSpan"]:nth-child(2) button[aria-label="Mute mic"]', | |
unmute_guest = 'div[class*="Cards__Wrap"] > span[class*="Tooltip__StyledSpan"]:nth-child(2) button[aria-label="Unmute mic"]'; | |
const delay = (delay) => { | |
return new Promise(resolve => setTimeout(resolve, delay)); | |
} | |
const activate = (path) => { | |
const element = d.querySelector(path); | |
if (element) { | |
return element.click() | |
} | |
} | |
const trigger = async (e) => { | |
if (e.key == 'F16') { | |
console.log('F16 - Solo host'); | |
activate(solo_host); | |
} | |
if (e.key == 'F17') { | |
console.log('F17 - Solo guest'); | |
activate(solo_guest); | |
} | |
if (e.key == 'F18') { | |
console.log('F18 - Crop layout'); | |
activate(cropped_layout); | |
} | |
if (e.key == 'F13') { | |
console.log('F13 - Go live'); | |
activate(music_button); | |
activate(solo_host); | |
activate(wait_screen_button); | |
activate(mute_host); | |
activate(mute_guest); | |
activate(go_live); | |
await delay(500); | |
activate(go_live_activate); | |
} | |
if (e.key == 'F14') { | |
console.log('F14 - Start Show'); | |
activate(wait_screen_button); | |
activate(unmute_host); | |
} | |
if (e.key == 'F15') { | |
console.log('F15 - Play Intro'); | |
activate(unmute_host); | |
activate(unmute_guest); | |
activate(music_button); | |
activate(video_button); | |
await delay(1000); | |
activate(cropped_layout); | |
await delay(16000); | |
activate(ticker_banner) | |
} | |
} | |
const observer = new MutationObserver(function(mutations) { | |
mutations.forEach(function(mutation) { | |
mutation.addedNodes.forEach(function(addedNode) { | |
const className = addedNode.className; | |
if (typeof className === 'string') { | |
if (addedNode.className.includes('Studio__DesktopWrap')) { | |
d.addEventListener('keydown', trigger, false); | |
observer.disconnect(); | |
} | |
} | |
}); | |
}); | |
}); | |
observer.observe(d.body, {childList: true, subtree: true}); | |
})(document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment