From dcdd51fce281cd817274aec2c88fd5ee33873516 Mon Sep 17 00:00:00 2001 From: goodtube4u Date: Fri, 13 Jun 2025 22:29:09 +1000 Subject: [PATCH] Re-add endscreen thumbnails --- beta/goodtube-embed.user.js | 45 +++++++++++++++++++++++++++++++++++-- goodtube.user.js | 45 +++++++++++++++++++++++++++++++++++-- 2 files changed, 86 insertions(+), 4 deletions(-) diff --git a/beta/goodtube-embed.user.js b/beta/goodtube-embed.user.js index 22a4aa3..76759d0 100644 --- a/beta/goodtube-embed.user.js +++ b/beta/goodtube-embed.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name GoodTube // @namespace http://tampermonkey.net/ -// @version 2.012 +// @version 2.013 // @description Removes 100% of Youtube ads. // @author GoodTube // @updateURL https://github.com/goodtube4u/goodtube/raw/refs/heads/main/goodtube.user.js @@ -1938,10 +1938,48 @@ // Fix fullscreen button issues goodTube_iframe_fixFullScreenButton(); + // Fix end screen links + goodTube_iframe_fixEndScreenLinks(); + // Run actions again in 100ms to loop this function setTimeout(goodTube_iframe_actions, 100); } + // Fix end screen links (so they open in the same window) + function goodTube_iframe_fixEndScreenLinks() { + let endScreenLinks = document.querySelectorAll('.ytp-videowall-still'); + endScreenLinks.forEach(link => { + // Remove any event listeners that Youtube adds + link.addEventListener('click', (event) => { + event.preventDefault(); + event.stopImmediatePropagation(); + + // On click, redirect the top window to the correct location + window.top.location.href = link.href; + }, true); + + link.addEventListener('mousedown', (event) => { + event.preventDefault(); + event.stopImmediatePropagation(); + }, true); + + link.addEventListener('mouseup', (event) => { + event.preventDefault(); + event.stopImmediatePropagation(); + }, true); + + link.addEventListener('touchstart', (event) => { + event.preventDefault(); + event.stopImmediatePropagation(); + }, true); + + link.addEventListener('touchend', (event) => { + event.preventDefault(); + event.stopImmediatePropagation(); + }, true); + }); + } + // Style the iframe function goodTube_iframe_style() { let style = document.createElement('style'); @@ -1955,7 +1993,6 @@ .ytp-cued-thumbnail-overlay, .ytp-paid-content-overlay, .ytp-impression-link, - .ytp-endscreen-content, .ytp-ad-progress-list, .ytp-endscreen-next, .ytp-endscreen-previous, @@ -1964,6 +2001,10 @@ display: none !important; } + .html5-endscreen { + top: 0 !important; + } + /* Make next and prev buttons not disabled */ .ytp-prev-button, .ytp-next-button { diff --git a/goodtube.user.js b/goodtube.user.js index 22a4aa3..76759d0 100644 --- a/goodtube.user.js +++ b/goodtube.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name GoodTube // @namespace http://tampermonkey.net/ -// @version 2.012 +// @version 2.013 // @description Removes 100% of Youtube ads. // @author GoodTube // @updateURL https://github.com/goodtube4u/goodtube/raw/refs/heads/main/goodtube.user.js @@ -1938,10 +1938,48 @@ // Fix fullscreen button issues goodTube_iframe_fixFullScreenButton(); + // Fix end screen links + goodTube_iframe_fixEndScreenLinks(); + // Run actions again in 100ms to loop this function setTimeout(goodTube_iframe_actions, 100); } + // Fix end screen links (so they open in the same window) + function goodTube_iframe_fixEndScreenLinks() { + let endScreenLinks = document.querySelectorAll('.ytp-videowall-still'); + endScreenLinks.forEach(link => { + // Remove any event listeners that Youtube adds + link.addEventListener('click', (event) => { + event.preventDefault(); + event.stopImmediatePropagation(); + + // On click, redirect the top window to the correct location + window.top.location.href = link.href; + }, true); + + link.addEventListener('mousedown', (event) => { + event.preventDefault(); + event.stopImmediatePropagation(); + }, true); + + link.addEventListener('mouseup', (event) => { + event.preventDefault(); + event.stopImmediatePropagation(); + }, true); + + link.addEventListener('touchstart', (event) => { + event.preventDefault(); + event.stopImmediatePropagation(); + }, true); + + link.addEventListener('touchend', (event) => { + event.preventDefault(); + event.stopImmediatePropagation(); + }, true); + }); + } + // Style the iframe function goodTube_iframe_style() { let style = document.createElement('style'); @@ -1955,7 +1993,6 @@ .ytp-cued-thumbnail-overlay, .ytp-paid-content-overlay, .ytp-impression-link, - .ytp-endscreen-content, .ytp-ad-progress-list, .ytp-endscreen-next, .ytp-endscreen-previous, @@ -1964,6 +2001,10 @@ display: none !important; } + .html5-endscreen { + top: 0 !important; + } + /* Make next and prev buttons not disabled */ .ytp-prev-button, .ytp-next-button {