Skip to content

Instantly share code, notes, and snippets.

@rishubil
Last active October 19, 2021 12:02
Show Gist options
  • Save rishubil/2003b5a21eba8b00b97fd1cb7b964cfa to your computer and use it in GitHub Desktop.
Save rishubil/2003b5a21eba8b00b97fd1cb7b964cfa to your computer and use it in GitHub Desktop.
fixed-nightbot-autodj.user.js
// ==UserScript==
// @name Fixed Nightbot AutoDJ
// @namespace fixed-nightbot-autodj
// @author Nesswit
// @version 0.1
// @description Nightbot AutoDJ player has fixed position
// @downloadURL https://gist.github.com/rishubil/2003b5a21eba8b00b97fd1cb7b964cfa/raw/fixed-nightbot-autodj.user.js
// @updateURL https://gist.github.com/rishubil/2003b5a21eba8b00b97fd1cb7b964cfa/raw/fixed-nightbot-autodj.user.js
// @include https://nightbot.tv/song_requests
// @match about:blank
// @grant GM_addStyle
// @run-at document-idle
// ==/UserScript==
GM_addStyle(`
html.fixed-player {
scrollbar-width: none;
margin-top: calc((9 / 16) * 100vw);
}
youtube-player.fixed-player {
position: fixed;
width: 100%;
top: 0;
left: 0;
z-index: 1000000;
}
youtube-player.fixed-player #yt_player {
width: 100%;
height: calc((9 / 16) * 100vw);
}
#fixed-button {
position: fixed;
width: 30px;
height: 30px;
border-radius: 15px;
top: 5px;
left: 5px;
z-index: 10000000;
}
#fixed-button:hover {
background: #00a9b6;
cursor: pointer;
}
`);
var elemDiv = document.createElement('div');
elemDiv.setAttribute("id", "fixed-button");
document.body.appendChild(elemDiv);
elemDiv.addEventListener("click", function(e) {
e.preventDefault();
var player = document.querySelector('youtube-player');
if (player !== undefined) {
document.querySelector('html').classList.toggle('fixed-player');
player.classList.toggle('fixed-player');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment