Skip to content

Commit 50faed9

Browse files
committed
Update X-Downloader.user.js
1 parent 04e946a commit 50faed9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

X-Downloader/X-Downloader.user.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,14 @@
128128
show(e.target.parentNode.parentNode);
129129
}
130130
};
131+
function isElementVisible(el) {
132+
const rect = el.getBoundingClientRect();
133+
return rect.top < window.innerHeight && rect.top > 0 && rect.bottom >= 0;
134+
}
131135
function findFirstVisibleElement(selector) {
132136
const elements = document.querySelectorAll(selector);
133137
const firstVisibleElement = Array.from(elements).find(el => {
134-
const rect = el.getBoundingClientRect();
135-
return rect.top < window.innerHeight && rect.top > 0 && rect.bottom >= 0;
138+
return isElementVisible(el);
136139
});
137140
return firstVisibleElement;
138141
}
@@ -141,6 +144,7 @@
141144
clearTimeout(checkTimer);
142145
if (e.target == downloadBtn) return;
143146
checkTimer = setTimeout(() => {
147+
if (isElementVisible(downloadBtn)) return;
144148
let target = findFirstVisibleElement("[data-testid='card.layoutLarge.media']");
145149
if (target) {
146150
return show(target.parentNode);

0 commit comments

Comments
 (0)