From 11df4d170628cf9e89e88b0551be89b446deae9e Mon Sep 17 00:00:00 2001 From: Thiago Ferreira Date: Wed, 14 Sep 2022 11:53:13 -0300 Subject: HOTFIX: added aditional check for like/dislike buttons inside ACTIVE Viewport In certain cases (see issue #741), the like/dislike buttons would be considered IN the viewport, despite its parent elements being hidden and its DOMRect being 0 on all sides. This way, added an additional check for considering these "hidden" buttons as NOT in the Viewport. --- Extensions/UserScript/Return Youtube Dislike.user.js | 3 +++ Extensions/combined/src/utils.js | 3 +++ 2 files changed, 6 insertions(+) diff --git a/Extensions/UserScript/Return Youtube Dislike.user.js b/Extensions/UserScript/Return Youtube Dislike.user.js index b9ffa27..bbf9abe 100644 --- a/Extensions/UserScript/Return Youtube Dislike.user.js +++ b/Extensions/UserScript/Return Youtube Dislike.user.js @@ -58,6 +58,9 @@ function isInViewport(element) { const height = innerHeight || document.documentElement.clientHeight; const width = innerWidth || document.documentElement.clientWidth; return ( + // When short (channel) is ignored, the element (like/dislike AND short itself) is + // hidden with a 0 DOMRect. In this case, consider it outside of Viewport + !(rect.top == 0 && rect.left == 0 && rect.bottom == 0 && rect.right == 0) && rect.top >= 0 && rect.left >= 0 && rect.bottom <= height && diff --git a/Extensions/combined/src/utils.js b/Extensions/combined/src/utils.js index b92bc0c..e789815 100644 --- a/Extensions/combined/src/utils.js +++ b/Extensions/combined/src/utils.js @@ -87,6 +87,9 @@ function isInViewport(element) { const height = innerHeight || document.documentElement.clientHeight; const width = innerWidth || document.documentElement.clientWidth; return ( + // When short (channel) is ignored, the element (like/dislike AND short itself) is + // hidden with a 0 DOMRect. In this case, consider it outside of Viewport + !(rect.top == 0 && rect.left == 0 && rect.bottom == 0 && rect.right == 0) && rect.top >= 0 && rect.left >= 0 && rect.bottom <= height && -- cgit v1.2.3