From cbaebbca928836cdd6ecf57a9f25e60d2bc52f42 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Wed, 22 May 2019 15:51:37 +0300 Subject: behavior: Extract links from plain-text documents --- crocoite/data/extract-links.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'crocoite') 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
. 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() */
 })();
-- 
cgit v1.2.3