JavaScript post-processing step to replace specific function/method calls with other bits of JavaScript