Applescript helper tool for javascript in browser (Safari)?

Hi, wondering if there are any Applescript tools or methods that can help see what all the objects on a web page are – the DOM – and how to address them, by name or by id or…?

I figure since Applescript can “do” javascripts in Safari, I could use some basic javascript code snippet templates to operate on the page by using the information about DOM objects to fill in the necessary names or IDs. Or if anyone has a better method regarding Applescripting web pages, I would be insanely grateful to learn it, thanks!