As you were able to do it in the sales_order.js so the custom script need to be done on that document (Sales Order). And how to do custom script, this is possible by writing custom script in the awesome bar or from Setup → Customize → Custom Script.
If you do not need to use custom script, then there is another long way that you can find it in this link: