diff options
Diffstat (limited to 'auto_detect_link.js')
-rw-r--r-- | auto_detect_link.js | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/auto_detect_link.js b/auto_detect_link.js index e5b3e30..55627d9 100644 --- a/auto_detect_link.js +++ b/auto_detect_link.js @@ -238,9 +238,15 @@ } + // 要素が表示されているか? + function isVisible (element) { + return !(element.style && element.style.display.match(/none/)) && (!element.parentNode || isVisible(element.parentNode)) + } + + // リンクのフィルタ - function linkFilter (link) { - return link.href && !link.href.match(/@/) && link.href.match(/^((https?|file|ftp):\/\/|javascript:)/) && link.textContent; + function linkElementFilter (elem) { + return isVisible(elem) && elem.href && !elem.href.match(/@/) && elem.href.match(/^((https?|file|ftp):\/\/|javascript:)/) && elem.textContent; } @@ -250,7 +256,7 @@ var result = []; // Anchor for each (let it in content.document.links) { - if (linkFilter(it)) + if (linkElementFilter(it)) result.push({ type: 'link', frame: content, |