post-macro passage copying

I’m writing a game which involves a lot of Twine 2 SugarCube’s <> macro, and I want to make a downloadable transcript button. To this end, I want to copy the text of a passage AFTER all of the macros in it have been applied and resolved. Is there an existing script to do something like this? Is there an easy way to make a script myself (not knowing much JS) or, as one guy suggested, does the only solution involve digging pretty deep into the Twine source code?

I’m kind of surprised no one’s made a Twine transcript script yet, but I don’t see one on a fast search.

Without looking at how Twine works - I would suggest creating a different kind of change-passages link. Before carrying out the normal Twine change-passage sequence, it would append the current text to a string variable (and then you could download the entire string to text at the end).

There may be a better way. I’m a beginner with Javascript myself.