From de7883329bb3d2a5a5a12cd278970b04107a0097 Mon Sep 17 00:00:00 2001 From: usk Date: Sun, 24 Dec 2017 06:14:17 +0900 Subject: [PATCH] do not follow link which has aria-hidden attribute or aria-disabled attribute --- src/content/components/common/follow.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/content/components/common/follow.js b/src/content/components/common/follow.js index 7717154..42dd897 100644 --- a/src/content/components/common/follow.js +++ b/src/content/components/common/follow.js @@ -30,6 +30,21 @@ const inViewport = (win, element, viewSize, framePosition) => { return true; }; +const isAriaHiddenOrAriaDisabled = (win, element) => { + if (!element || win.document.documentElement === element) { + return false; + } + for (let attr of ['aria-hidden', 'aria-disabled']) { + if (element.hasAttribute(attr)) { + let hidden = element.getAttribute(attr).toLowerCase(); + if (hidden === '' || hidden === 'true') { + return true; + } + } + } + return isAriaHiddenOrAriaDisabled(win, element.parentNode); +}; + export default class Follow { constructor(win, store) { this.win = win; @@ -171,6 +186,7 @@ export default class Follow { style.visibility !== 'hidden' && element.type !== 'hidden' && element.offsetHeight > 0 && + !isAriaHiddenOrAriaDisabled(win, element) && inViewport(win, element, viewSize, framePosition); }); return filtered;