您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
10/30/2021, 12:35:27 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.6
- // @author -
- // @description 10/30/2021, 12:35:27 AM
- // ==/UserScript==
- function idle_waiter(wait_for_idle_ms, on_idle_callback) {
- // source: https://stackoverflow.com/a/47406751
- var action = function(o) {
- o.disconnect();
- on_idle_callback();
- }
- var resetTimer = function(changes, observer) {
- clearTimeout(timer);
- timer = setTimeout(action, wait_for_idle_ms, observer);
- }
- var observer = new MutationObserver(resetTimer);
- var timer = setTimeout(action, wait_for_idle_ms, observer); // wait for the page to stay still for 3 seconds
- observer.observe(document, {childList: true, subtree: true});
- }
- function removeAllByClass(classes) {
- classes.forEach(cls => {
- Array.from(document.getElementsByClassName(cls)).map(e => e.remove());
- });
- }
- function cleanupOverlays() {
- const classes = [
- 'ytp-paid-content-overlay', // paid promotion notification overlay in the bottom left corner
- 'ytp-pause-overlay', // "More Videos" overlay on paused embeds
- 'ytp-ce-element', // covering overlays at the end of the video
- 'iv-branding', // branding overlay in the bottom right corner
- 'ytp-cards-teaser', // info cards in the top right corner
- 'ytp-cards-button-icon', // info cards in the top right corner
- 'ytp-cards-button-title'
- ];
- removeAllByClass(classes);
- }
- // overkill but works
- idle_waiter(100, cleanupOverlays);
- idle_waiter(500, cleanupOverlays);
- idle_waiter(1000, cleanupOverlays);