From bcf9ba015056057e613bc970863e944a785e42d4 Mon Sep 17 00:00:00 2001 From: anekos Date: Tue, 5 Aug 2008 11:19:38 +0000 Subject: ・見えていない要素は無視するようにした。 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@17111 d0d07461-0603-4401-acd4-de1884942a52 --- auto_detect_link.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'auto_detect_link.js') 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, -- cgit v1.2.3