Skip to main content
Commonmark migration
Source Link

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.

    Have post that was prettified on page load.

    pictures!

  2. Do some editing.

    edit panel open

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

    oh no!

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?

(It occurs to me there are other scenarios, such as someone else edits the post whilst you're reading it, and that bar appears at the top offering to reload the answer. If there's some solution that helps in these situations in general, that would be excellent.)

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?

(It occurs to me there are other scenarios, such as someone else edits the post whilst you're reading it, and that bar appears at the top offering to reload the answer. If there's some solution that helps in these situations in general, that would be excellent.)

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!

  2. Do some editing.

    edit panel open

  3. 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?

(It occurs to me there are other scenarios, such as someone else edits the post whilst you're reading it, and that bar appears at the top offering to reload the answer. If there's some solution that helps in these situations in general, that would be excellent.)

replaced http://meta.boardgames.stackexchange.com/ with https://boardgames.meta.stackexchange.com/
Source Link

I recently built a userscript for Board Games Stack Exchangea 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?

(It occurs to me there are other scenarios, such as someone else edits the post whilst you're reading it, and that bar appears at the top offering to reload the answer. If there's some solution that helps in these situations in general, that would be excellent.)

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?

(It occurs to me there are other scenarios, such as someone else edits the post whilst you're reading it, and that bar appears at the top offering to reload the answer. If there's some solution that helps in these situations in general, that would be excellent.)

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?

(It occurs to me there are other scenarios, such as someone else edits the post whilst you're reading it, and that bar appears at the top offering to reload the answer. If there's some solution that helps in these situations in general, that would be excellent.)

added 268 characters in body
Source Link

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?

(It occurs to me there are other scenarios, such as someone else edits the post whilst you're reading it, and that bar appears at the top offering to reload the answer. If there's some solution that helps in these situations in general, that would be excellent.)

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?

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?

(It occurs to me there are other scenarios, such as someone else edits the post whilst you're reading it, and that bar appears at the top offering to reload the answer. If there's some solution that helps in these situations in general, that would be excellent.)

edited tags
Link
Brock Adams
  • 13k
  • 5
  • 39
  • 64
Loading
added 189 characters in body
Source Link
Loading
Source Link
Loading