aboutsummaryrefslogtreecommitdiff
path: root/src/content/follow.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/follow.js')
-rw-r--r--src/content/follow.js14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/content/follow.js b/src/content/follow.js
index f9cc380..7d69b45 100644
--- a/src/content/follow.js
+++ b/src/content/follow.js
@@ -124,13 +124,25 @@ export default class Follow {
return chars;
}
+ static inWindow(window, element) {
+ let {
+ top, left, bottom, right
+ } = element.getBoundingClientRect();
+ return (
+ top >= 0 && left >= 0 &&
+ bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
+ right <= (window.innerWidth || document.documentElement.clientWidth)
+ );
+ }
+
static getTargetElements(doc) {
let all = doc.querySelectorAll('a,button,input,textarea');
let filtered = Array.prototype.filter.call(all, (element) => {
let style = window.getComputedStyle(element);
return style.display !== 'none' &&
style.visibility !== 'hidden' &&
- element.type !== 'hidden';
+ element.type !== 'hidden' &&
+ Follow.inWindow(window, element);
});
return filtered;
}