diff options
author | Timmy Keller <tjk@tjkeller.xyz> | 2024-08-10 19:34:54 -0500 |
---|---|---|
committer | Timmy Keller <tjk@tjkeller.xyz> | 2024-08-10 19:34:54 -0500 |
commit | 5cd7617d4467693feced81b440eee8782aebdb02 (patch) | |
tree | 68a854bc69f9ee16eedd82d83fb0d091795f6bc4 /youtube/disable-mini-player.js | |
download | userscripts-5cd7617d4467693feced81b440eee8782aebdb02.tar.xz userscripts-5cd7617d4467693feced81b440eee8782aebdb02.zip |
initial commit
Diffstat (limited to 'youtube/disable-mini-player.js')
-rw-r--r-- | youtube/disable-mini-player.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/youtube/disable-mini-player.js b/youtube/disable-mini-player.js new file mode 100644 index 0000000..da8349c --- /dev/null +++ b/youtube/disable-mini-player.js @@ -0,0 +1,31 @@ +// ==UserScript== +// @name Disable YouTube Miniplayer +// @author tjkeller.xyz +// @include *youtube.com* +// @grant GM_addStyle +// ==/UserScript== + +// Remove home and shorts button +GM_addStyle(` + ytd-miniplayer, + .ytp-miniplayer-button + { + display: none !important; /* Needs !important flag */ + } +`) + + +// Pause video before navigating +document.body.addEventListener("yt-navigate-start", () => { + if (window.location.pathname == "/watch") + document.querySelector("ytd-player video").pause() +}) + +// Close miniplayer by clicking close button in code +document.body.addEventListener("yt-navigate-finish", () => { + setTimeout(() => { + const miniplayerCloseButton = document.querySelector("button.ytp-miniplayer-close-button") + if (miniplayerCloseButton) + miniplayerCloseButton.click() + }, 500) // Wait 500ms to close consistantly since miniplayer loads a little after this event +}) |