It looks like your changes will lead to the javascript being embedded twice in the output. Once in the header and once in the footer. The problem is that the $content var is being modified in the inject_js() and post_content() functions.
i think instead of having the footer insert code in the post_content() function the change should be made solely in the inject_js() function.
Take a look at the attached wp_minify.php file which I've been using for the past year on my own site and it appears to be working just fine.
Note that this file will ONLY embed the javascript at the end of the content. It doesn't provide any configuration options.