blob: 5199a63ed533401794ba028ac09ce6b27d245940 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
/* Extract links from a page
*/
/* --- copy&paste from click.js --- */
/* Element is visible if itself and all of its parents are
*/
function isVisible (o) {
if (o === null || !(o instanceof Element)) {
return true;
}
let style = window.getComputedStyle (o);
if ('parentNode' in o) {
return style.display !== 'none' && isVisible (o.parentNode);
} else {
return style.display !== 'none';
}
}
/* Elements are considered clickable if they are a) visible and b) not
* disabled
*/
function isClickable (o) {
return !o.hasAttribute ('disabled') && isVisible (o);
}
/* --- end copy&paste */
let x = document.body.querySelectorAll('a[href]');
let ret = [];
for (let i=0; i < x.length; i++) {
if (isClickable (x[i])) {
ret.push (x[i].href);
}
}
ret; /* immediately return results, for use with Runtime.evaluate() */
|