There are a couple of magic functions you can use to inspect and parse an HTML document while you’re reading it in the browser.
$x()
allows you to check an XPATH. It’s basically a shorthand for document.evaluate(xpath, document);
$$()
allows you to check a CSS Selector. It’s basically a shorthand for document.querySelectorAll(css);
On Chrome $x()
returns an XPathResult — just like document.evaluate()
— which can only be inspected with the function iterateNext()
. But on Safari and Firefox $x()
will return an Array — just like $$()
and document.querySelectorAll()
.
These shortcut functions can save some typing and mental effort.
Thanks to Andrew Krug from lazycoder.io for pointing out $x()
.