You just described the Macaroni plugin system — plugins are literally appended as <script> tags before the closing </html> tag.
Note that you don't actually need a closing </html> tag.
The closing </html> tag is mandatory because Macaroni Messenger plugins are inserted immediately before it. This is the convention defined by the plugin system.