It's hacky, but if you wanted to do it without a plugin / with existing settings, you could apply the javascript in the settings in Site administration > Appearance> Additional HTML (probably additionalhtmlfooter).
General developer forum
Add Javascript to Moodle custom menu
This discussion has been locked so you can no longer reply to it.