restructured scripts, misc fixes

I didn't like having two separate files for functions and hotkeys, it
felt like it was discouraging me from modifying them (don't ask me why).
I also took the liberty to fix some longstanding bugs like one of the
thumb buttons crashing the Firefox plugin container and changed the
script encodings.