From 5d0c33c1a678ceb91f82c632e34345fe815e7e29 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Tue, 19 Sep 2017 21:54:50 +0900 Subject: [PATCH 1/4] move hint to front --- src/content/hint.css | 1 + 1 file changed, 1 insertion(+) diff --git a/src/content/hint.css b/src/content/hint.css index a0f1233..e68dfee 100644 --- a/src/content/hint.css +++ b/src/content/hint.css @@ -4,4 +4,5 @@ font-weight: bold; position: absolute; text-transform: uppercase; + z-index: 100000; } From 2286448b6839251aa490c226cb2384a14b937662 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Tue, 19 Sep 2017 21:55:25 +0900 Subject: [PATCH 2/4] use offsetHeight to check element visibility --- src/content/follow.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/content/follow.js b/src/content/follow.js index 7d69b45..eedd1ed 100644 --- a/src/content/follow.js +++ b/src/content/follow.js @@ -142,6 +142,7 @@ export default class Follow { return style.display !== 'none' && style.visibility !== 'hidden' && element.type !== 'hidden' && + element.offsetHeight > 0 && Follow.inWindow(window, element); }); return filtered; From a88890809cc6c2b8a6a4cff8a460b1d56f1b771e Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Tue, 19 Sep 2017 22:23:15 +0900 Subject: [PATCH 3/4] fix hint style --- src/content/hint.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/content/hint.css b/src/content/hint.css index e68dfee..119dd21 100644 --- a/src/content/hint.css +++ b/src/content/hint.css @@ -5,4 +5,6 @@ position: absolute; text-transform: uppercase; z-index: 100000; + font-size: 12px; + color: black; } From 7c943eb675eba4790b33378f0e5ec1ffcff623c4 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Tue, 19 Sep 2017 22:23:23 +0900 Subject: [PATCH 4/4] click link and avoid invalid links --- src/content/index.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/content/index.js b/src/content/index.js index 159429e..8fb142a 100644 --- a/src/content/index.js +++ b/src/content/index.js @@ -9,15 +9,25 @@ import messages from '../messages'; consoleFrames.initialize(window.document); const startFollows = (newTab) => { - let follow = new Follow(window.document, newTab); + let follow = new Follow(window.document); follow.onActivated((element) => { switch (element.tagName.toLowerCase()) { case 'a': - return browser.runtime.sendMessage({ - type: messages.OPEN_URL, - url: element.href, - newTab - }); + if (newTab) { + // getAttribute() to avoid to resolve absolute path + let href = element.getibute('href'); + + // eslint-disable-next-line no-script-url + if (!href || href === '#' || href.startsWith('javascript:')) { + return; + } + return browser.runtime.sendMessage({ + type: messages.OPEN_URL, + url: element.href, + newTab + }); + } + return element.click(); case 'input': switch (element.type) { case 'file':