Do you have a custom app available? If so, you can add your script there and have it linked into any document by adding
app_include_js = [
place your script file in yourapp/public/js/yourscript.js
add to yourapp/public/build.json
If you are looking for a reference, you can look into https://github.com/libracore/erpnextswiss/blob/master/erpnextswiss/public/build.json
The base code of your script is executed when the document is loaded. You can make use to the jQuery document ready function to be sure the form is available and then apply your filter.
Hope this helps…