Quick Tip — Written on
Get names of all elements on a web page with JS
This tip is originally from Lea Verou.
Get the names of all elements on the page:
let names = [...new Set($$("*").map(e => e.nodeName.toLowerCase()))];
Get all names in the body:
let names = [...new Set($$("body *").map(e => e.nodeName.toLowerCase()))];
Get all class names used:
let classes = [...new Set($$("[class]").flatMap(e => [...e.classList]))];