From c50f463bc12da7e3a5de490b714b4ff1ea8d3e56 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Mon, 21 Aug 2017 21:01:29 +0900 Subject: add follow tests --- src/content/follow.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/content') diff --git a/src/content/follow.js b/src/content/follow.js index c0b7a44..d678351 100644 --- a/src/content/follow.js +++ b/src/content/follow.js @@ -105,6 +105,20 @@ export default class Follow { } static getTargetElements(doc) { - return doc.querySelectorAll('a') + let all = doc.querySelectorAll('a'); + let filtered = Array.prototype.filter.call(all, (e) => { + return Follow.isVisibleElement(e); + }); + return filtered; + } + + static isVisibleElement(element) { + var style = window.getComputedStyle(element); + if (style.display === 'none') { + return false; + } else if (style.visibility === 'hidden') { + return false; + } + return true; } } -- cgit v1.2.3