10/27/2021, 12:22:39 AM
目前為
// ==UserScript==
// @name Youtube: Remove Overlays
// @namespace https://greasyfork.org/en/users/221281-klaufir
// @match https://www.youtube.com/embed/*
// @match https://www.youtube.com/watch?v=*
// @grant none
// @version 1.4
// @author -
// @description 10/27/2021, 12:22:39 AM
// ==/UserScript==
function removeElements(elems) {
if (elems)
Array.from(elems).map(e => e.remove());
}
function removeElement(elem) {
elem?.remove();
}
function retrier(queryFn, onSuccess, tries, retryInterval) {
if (tries <= 0)
return;
var queryResult = queryFn()
if (!queryResult || (queryResult?.length ?? -1) == 0) {
setTimeout(function() {retrier(queryFn, onSuccess, tries-1, retryInterval); }, retryInterval);
return;
}
onSuccess(queryResult);
}
// Remove "More Videos" overlay on paused embeds
function getMoreVideosOverlay() {
return document?.querySelector(".ytp-pause-overlay.ytp-scroll-min");
}
retrier(getMoreVideosOverlay,
removeElement,
/* tries: */ 10,
/* retryInterval:*/ 1000);
// Remove covering overlays at the end of the video
function getCoveringOverlays() {
return document?.querySelectorAll('.ytp-ce-element');
}
retrier(getCoveringOverlays,
removeElements,
/* tries: */ 10,
/* retryInterval:*/ 1000);
// Remove paid promotion notification overlay in the bottom left corner
function getPaidPromotionsOverlay() {
return document?.querySelector('.ytp-paid-content-overlay-text');
}
retrier(getPaidPromotionsOverlay,
removeElement,
/* tries: */ 10,
/* retryInterval:*/ 1000);
// Remove info cards in the top right corner
function getCardsTeaser() {
return document?.querySelector('.ytp-cards-teaser');
}
retrier(getCardsTeaser,
removeElement,
/* tries: */ 10,
/* retryInterval:*/ 1000);
// Remove branding overlay in the bottom right corner
function getBranding() {
return document?.querySelector('.iv-branding');
}
retrier(getBranding,
removeElement,
/* tries: */ 10,
/* retryInterval:*/ 1000);