mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-12-01 18:31:24 +01:00
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.
This commit is contained in:
2 files changed
+6
No files matched your search
@@ -58,6 +58,9 @@ function isInViewport(element) {
|
|||||||
const height = innerHeight || document.documentElement.clientHeight;
|
const height = innerHeight || document.documentElement.clientHeight;
|
||||||
const width = innerWidth || document.documentElement.clientWidth;
|
const width = innerWidth || document.documentElement.clientWidth;
|
||||||
return (
|
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.top >= 0 &&
|
||||||
rect.left >= 0 &&
|
rect.left >= 0 &&
|
||||||
rect.bottom <= height &&
|
rect.bottom <= height &&
|
||||||
|
|||||||
@@ -87,6 +87,9 @@ function isInViewport(element) {
|
|||||||
const height = innerHeight || document.documentElement.clientHeight;
|
const height = innerHeight || document.documentElement.clientHeight;
|
||||||
const width = innerWidth || document.documentElement.clientWidth;
|
const width = innerWidth || document.documentElement.clientWidth;
|
||||||
return (
|
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.top >= 0 &&
|
||||||
rect.left >= 0 &&
|
rect.left >= 0 &&
|
||||||
rect.bottom <= height &&
|
rect.bottom <= height &&
|
||||||
|
|||||||
Reference in new issue
Block a user