Last active
November 30, 2021 07:38
-
-
Save lassekongo83/959caf90124219fc3aa0963209896c0f to your computer and use it in GitHub Desktop.
Auto-close the miniplayer and remove the miniplayer button on the player
This file contains 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 Auto-close YouTube miniplayer | |
// @namespace Violentmonkey Scripts | |
// @match https://www.youtube.com/* | |
// @grant none | |
// @version 1.0 | |
// @author Frellwit | |
// @description Auto-close the miniplayer and remove the miniplayer button on the player | |
// ==/UserScript== | |
function clickButton(selector){ | |
let elm = document.querySelectorAll(selector)[0]; | |
if (elm){ elm.click(); } | |
} | |
function addStyle(styleString) { | |
const style = document.createElement('style'); | |
style.textContent = styleString; | |
document.head.append(style); | |
} | |
function autoCloseMP() { | |
// autoclick the close button on the miniplayer when the progressbar is finished | |
// yt-navigate-finish would be better, but it seems to be too fast | |
document.addEventListener('transitionend', function(e) { | |
if (document.getElementById('progress') !== null) { | |
if (e.target.id === 'progress') { | |
clickButton('.ytp-miniplayer-close-button'); | |
} | |
} | |
}); | |
// hide the miniplayer icon | |
addStyle(`.ytp-miniplayer-button {display:none!important;}`); | |
} | |
autoCloseMP(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment