I want to write a userscript that modifies the share dialog to add an extra field:
It's easy enough to retrieve and modify this dialog whilst it's on the page, but it gets added to the DOM only after the share button is clicked, so the puzzle is how to be aware of when that's the case.
A clear (but hacky) option to me is put an event listener on share buttons, wait for them to be clicked, set a timeout for 100ms, then find & modify whatever .share-tip
element exists on the page. However, I'm hoping there's a better way or a best practice identified by userscript authors.
What's the current best practice for detecting when the share dialog is open? Is there an event call exposed by the JavaScript StackExchange object which I should hook into?