Merge branch 'improve-follow'
This commit is contained in:
commit
2b6aca17b0
2 changed files with 13 additions and 3 deletions
|
@ -10,7 +10,6 @@ export default class Follow {
|
||||||
this.keys = [];
|
this.keys = [];
|
||||||
this.onActivatedCallbacks = [];
|
this.onActivatedCallbacks = [];
|
||||||
|
|
||||||
// TODO activate input elements and push button elements
|
|
||||||
let links = Follow.getTargetElements(doc);
|
let links = Follow.getTargetElements(doc);
|
||||||
|
|
||||||
this.addHints(links);
|
this.addHints(links);
|
||||||
|
|
|
@ -15,7 +15,7 @@ const startFollows = (newTab) => {
|
||||||
case 'a':
|
case 'a':
|
||||||
if (newTab) {
|
if (newTab) {
|
||||||
// getAttribute() to avoid to resolve absolute path
|
// getAttribute() to avoid to resolve absolute path
|
||||||
let href = element.getibute('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.startsWith('javascript:')) {
|
||||||
|
@ -27,6 +27,15 @@ const startFollows = (newTab) => {
|
||||||
newTab
|
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
|
||||||
|
});
|
||||||
|
}
|
||||||
return element.click();
|
return element.click();
|
||||||
case 'input':
|
case 'input':
|
||||||
switch (element.type) {
|
switch (element.type) {
|
||||||
|
@ -51,7 +60,9 @@ const startFollows = (newTab) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener('keypress', (e) => {
|
window.addEventListener('keypress', (e) => {
|
||||||
if (e.target instanceof HTMLInputElement) {
|
if (e.target instanceof HTMLInputElement ||
|
||||||
|
e.target instanceof HTMLTextAreaElement ||
|
||||||
|
e.target instanceof HTMLSelectElement) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
browser.runtime.sendMessage({
|
browser.runtime.sendMessage({
|
||||||
|
|
Reference in a new issue