diff options
author | Thiago Ferreira <thiagocf042@gmail.com> | 2022-09-14 17:53:13 +0300 |
---|---|---|
committer | Thiago Ferreira <thiagocf042@gmail.com> | 2022-09-14 17:53:13 +0300 |
commit | 11df4d170628cf9e89e88b0551be89b446deae9e (patch) | |
tree | 6ef3d797b64cd9210565f0b637dbded4ca55c359 /Extensions | |
parent | 9a7554ba3c42df157ffea9c122e1477765c1f511 (diff) |
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.
Diffstat (limited to 'Extensions')
-rw-r--r-- | Extensions/UserScript/Return Youtube Dislike.user.js | 3 | ||||
-rw-r--r-- | Extensions/combined/src/utils.js | 3 |
2 files changed, 6 insertions, 0 deletions
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 && |