add follow tests
This commit is contained in:
parent
d4d54ca496
commit
c50f463bc1
3 changed files with 35 additions and 1 deletions
|
@ -105,6 +105,20 @@ export default class Follow {
|
|||
}
|
||||
|
||||
static getTargetElements(doc) {
|
||||
return doc.querySelectorAll('a')
|
||||
let all = doc.querySelectorAll('a');
|
||||
let filtered = Array.prototype.filter.call(all, (e) => {
|
||||
return Follow.isVisibleElement(e);
|
||||
});
|
||||
return filtered;
|
||||
}
|
||||
|
||||
static isVisibleElement(element) {
|
||||
var style = window.getComputedStyle(element);
|
||||
if (style.display === 'none') {
|
||||
return false;
|
||||
} else if (style.visibility === 'hidden') {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue