summaryrefslogtreecommitdiff
path: root/crocoite
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2019-05-22 15:51:37 +0300
committerLars-Dominik Braun <lars@6xq.net>2019-05-22 15:51:37 +0300
commitcbaebbca928836cdd6ecf57a9f25e60d2bc52f42 (patch)
tree5cbdd3f3630d13902dff4acfc994f2cfb2b45a19 /crocoite
parent46137ca7d0033cb4f5cd0d5e38947fe59bb49ab3 (diff)
downloadcrocoite-cbaebbca928836cdd6ecf57a9f25e60d2bc52f42.tar.gz
crocoite-cbaebbca928836cdd6ecf57a9f25e60d2bc52f42.tar.bz2
crocoite-cbaebbca928836cdd6ecf57a9f25e60d2bc52f42.zip
behavior: Extract links from plain-text documents
Diffstat (limited to 'crocoite')
-rw-r--r--crocoite/data/extract-links.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/crocoite/data/extract-links.js b/crocoite/data/extract-links.js
index 483a35f..f3176da 100644
--- a/crocoite/data/extract-links.js
+++ b/crocoite/data/extract-links.js
@@ -34,5 +34,18 @@ let ret = [];
}
}
});
+
+/* If Chrome loads plain-text documents it’ll wrap them into <pre>. Check those
+ * for links as well, assuming the whole line is a link (i.e. list of links). */
+let x = document.querySelectorAll ('body > pre');
+for (let i=0; i < x.length; i++) {
+ if (isVisible (x[i])) {
+ x[i].innerText.split ('\n').forEach (function (s) {
+ if (s.match ('^https?://')) {
+ ret.push (s);
+ }
+ });
+ }
+}
return ret; /* immediately return results, for use with Runtime.evaluate() */
})();