aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-09-19 22:23:23 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2017-09-19 22:38:04 +0900
commit7c943eb675eba4790b33378f0e5ec1ffcff623c4 (patch)
treea2ab88d8d7792b595a5c3541e5122980e86390c4 /src
parenta88890809cc6c2b8a6a4cff8a460b1d56f1b771e (diff)
click link and avoid invalid links
Diffstat (limited to 'src')
-rw-r--r--src/content/index.js22
1 files 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':