|
|
@ -90,15 +90,16 @@ export default class FollowComponent { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
activate(element) { |
|
|
|
openLink(element) { |
|
|
|
switch (element.tagName.toLowerCase()) { |
|
|
|
if (!this.state.newTab) { |
|
|
|
case 'a': |
|
|
|
element.click(); |
|
|
|
if (this.state.newTab) { |
|
|
|
return; |
|
|
|
// getAttribute() to avoid to resolve absolute path
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let href = element.getAttribute('href'); |
|
|
|
let href = element.getAttribute('href'); |
|
|
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-script-url
|
|
|
|
// eslint-disable-next-line no-script-url
|
|
|
|
if (!href || href === '#' || href.startsWith('javascript:')) { |
|
|
|
if (!href || href === '#' || href.toLowerCase().startsWith('javascript:')) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
return browser.runtime.sendMessage({ |
|
|
|
return browser.runtime.sendMessage({ |
|
|
@ -107,16 +108,11 @@ export default class FollowComponent { |
|
|
|
newTab: this.state.newTab, |
|
|
|
newTab: this.state.newTab, |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
if (element.href.startsWith('http://') || |
|
|
|
|
|
|
|
element.href.startsWith('https://') || |
|
|
|
activate(element) { |
|
|
|
element.href.startsWith('ftp://')) { |
|
|
|
switch (element.tagName.toLowerCase()) { |
|
|
|
return browser.runtime.sendMessage({ |
|
|
|
case 'a': |
|
|
|
type: messages.OPEN_URL, |
|
|
|
return this.openLink(element, this.state.newTab); |
|
|
|
url: element.href, |
|
|
|
|
|
|
|
newTab: this.state.newTab, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return element.click(); |
|
|
|
|
|
|
|
case 'input': |
|
|
|
case 'input': |
|
|
|
switch (element.type) { |
|
|
|
switch (element.type) { |
|
|
|
case 'file': |
|
|
|
case 'file': |
|
|
|