You can integrate arbitrary javascript code using the Javascript SDK.
Plugins should not do things like change global variables, because it is extremely confusing for the user. They want to be able to control them with their own events, and not have plugins pull the rug out from under their feet and do things behind the scenes. It's possible, but I strongly discourage it.