summaryrefslogtreecommitdiff
path: root/crocoite/data
diff options
context:
space:
mode:
Diffstat (limited to 'crocoite/data')
-rw-r--r--crocoite/data/extract-links.js31
1 files changed, 28 insertions, 3 deletions
diff --git a/crocoite/data/extract-links.js b/crocoite/data/extract-links.js
index f2a37aa..5199a63 100644
--- a/crocoite/data/extract-links.js
+++ b/crocoite/data/extract-links.js
@@ -1,9 +1,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 = [];
-let index = 0;
-for( index=0; index < x.length; index++ ) {
- ret.push (x[index].href);
+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() */