Puoi usare auto_prepend_file. Lo script che aggiungi dovrà:

- avviare ob_start() con una callback
- nella callback esegui un replace di </body> con il tuo codice + </body>