Last active
October 19, 2021 12:02
-
-
Save rishubil/2003b5a21eba8b00b97fd1cb7b964cfa to your computer and use it in GitHub Desktop.
fixed-nightbot-autodj.user.js
This file contains hidden or 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 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