Has anyone used Javascript to detect and click a button on a web page?

And that's where it all goes horribly wrong...

It is a button, but it has a dynamically generated ID that corresponds to the UID of the post.

You'll be able to do something with @noisneil's macro but you'd still have to find a way to "get the UID of the post I'm looking at" -- and that's well beyond my limited JS skills!