This could be done with jQuery in an hour or two with properly defined content. You would need to identify a unique place in the document to generate the ToC as well as be able to identify the headers to be included. jQuery could even add Anchors in the content to allow for hyperlinks directly to the sections.
The actual syntax would vary depending on your structure and needs but basically you would use jQuery/javascript to grab the ToC Container, then use jQuery to search the rest of the page for the Header Text to be included and then dynamically build that list and write it into ToC Container as HTML. It would probably look something like this:
jQuery(".ClassOfHeaderText").each(function() {
/// build new ToC Html with title / links
newToCHtml += "<li>" + jQuery(this).text() + "</li>"
});
jQuery("#IDOrClassOfToCContainer").html(newToCHtml)