aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/youtube-disable-mini-player.user.js
blob: e9765cae900102aee6d8e2b276eda94ce3e32ccf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// ==UserScript==
// @name        Disable YouTube Miniplayer
// @description Disable YouTube's miniplayer feature by auto closing and not displaying it
// @author      tjkeller.xyz
// @include     *youtube.com*
// @grant       GM_addStyle
// @homepageURL https://git.tjkeller.xyz/userscripts/about
// @downloadURL https://git.tjkeller.xyz/userscripts/plain/scripts/youtube-disable-mini-player.user.js
// @version     1.1
// @author      tjkeller.xyz
// ==/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
})