Skip to main content
2 of 5
https links still get ignored by the linked questions sidebar :(
Ilmari Karonen
  • 1.4k
  • 10
  • 18

Load answers to a question with review-like wrapper HTML

I'm trying to implement this feature request in SOUP, but I'm having trouble figuring out a good way to actually load the answers.

  • I can just load the full question page (like this one, for example) and extract the answers off of it with jQuery. However, this gives me a bunch on non-functional UI elements (like tabs and vote buttons) that I don't really want, and it also ends up re-running any scripts embedded on the page. Surprisingly, despite those issues, it still seems to more or less work, but I really don't like it.

  • I can use an API /questions/{ids}/answers query with filter=withbody to get the answer bodies in a JSON wrapper (example). This has kind of the opposite problem — I only get the HTML for the answer body, and would have to manually reconstruct all the surrounding "wrapper" HTML based on the metadata in the JSON response. I don't really like this option either, if only because I don't like my user scripts full of hardcoded HTML code.

  • Finally, the undocumented(?) URL used to fetch the question previews for the close-as-duplicate popup, /posts/popup/close/search-originals/1?q=/questions/{id}, gives me almost exactly the kind of HTML I want (example). Alas, it seems to only work for questions that are actually eligible for being marked as duplicates, i.e. those that have at least one accepted or upvoted answer.

So, does anyone know of a convenient way (officially documented or not) to load the full answers to a question, including an HTML wrapper similar to what would normally be shown on the close vote review page (example)?

Ilmari Karonen
  • 1.4k
  • 10
  • 18