load content script all_frames and click link

jh-changes
Shin'ya Ueoka 7 years ago
parent bebf8e2327
commit fc90f78e26
  1. 1
      manifest.json
  2. 28
      src/content/components/follow.js

@ -14,6 +14,7 @@
},
"content_scripts": [
{
"all_frames": true,
"matches": [ "http://*/*", "https://*/*" ],
"js": [ "build/content.js" ]
}

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