In HOOK_preprocess_block() there is a variable $variables['block_html_id'] available which is the unique HTML ID of the block. Ideally the javascript should use that value, as it would allow the same block to be embedded twice, eg via Panels.

I haven't looked too thoroughly, but I'm guessing you would still need to record the block module and delta (maybe via a data-attribute) so you can retrieve the block from the database.

Does this sound as simple as I think it does?