aboutsummaryrefslogtreecommitdiff
path: root/youtube/disable-mini-player.js
blob: da8349ce1422cc80159aadf754903cbea05fc8d5 (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
// ==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
})