Automatically collapse More videos popup in YouTube.
当前为
// ==UserScript==
// @name Simplify Embedded YouTube Player
// @description Automatically collapse More videos popup in YouTube.
// @namespace https://greasyfork.org/users/1458847
// @license MIT
// @match https://www.youtube-nocookie.com/*
// @match https://www.youtube.com/embed/*
// @version 1.6
// ==/UserScript==
(function () {
"use strict";
var style = document.createElement("style");
style.textContent = `
div.ytp-pause-overlay{
visibility: hidden !important;
}
a.ytp-watermark{
visibility: hidden !important;
}
.ytp-paid-content-overlay{
visibility: hidden !important;
}
`;
document.querySelector("head").appendChild(style);
document.addEventListener(
"keydown",
function (event) {
const targetElement = event.target;
// dismiss subtitle background opacity setting key (w)
if (event.key.toLowerCase() === "w") {
preventPropagation(event);
}
}, true);
window.addEventListener("load", function () {
setTimeout(() => {
//clickPlayButton();
clickCollapseButton();
//clickPlayButton();
}, 100);
});
function preventPropagation(event){
event.preventDefault();
event.stopPropagation();
}
function clickElement(selector) {
const element = document.querySelector(selector);
if (element) element.click();
}
function clickPlayButton() {
clickElement(".ytp-button.ytp-large-play-button");
}
function clickCollapseButton() {
clickElement(".ytp-button.ytp-collapse");
}
function clickSubtitleButton() {
clickElement(".ytp-button.ytp-subtitles-button");
}
})();