Skip to main content
3 of 6
edited tags
Brock Adams
  • 13k
  • 5
  • 39
  • 64

How can a userscript detect when a post's been edited in place, so that it can do stuff to the newly edited post?

I recently built a userscript for Board Games Stack Exchange. On page load, it scans questions and answers for certain plaintext patterns and replaces them with some HTML, making the posts prettier.

It only works on page load, however. If someone hits edit and edits the post in place (where they get to do the edit and save process in an AJAXy way without leaving the page), then when they save their edit, their freshly-edited post will be reloaded and won't be prettified by the userscript.

Or if pictures make it clearer:

  1. Have post that was prettified on page load.

pictures!

  1. Do some editing.

edit panel open

  1. Save, post gets saved all AJAX-style and reloaded, and is no longer prettified.

oh no!

How can I have my userscript reliably detect that a post's finished being edited, and do stuff to the freshly reloaded post only once there's something to do stuff to?