You could do the following to inject javascript:
1) Create a javascript library with the function in it you want to run.
2) Modify the home ribbon and customize a button that's on that page (Edit for instance).
3) Add an enable rule that runs the function from your javascript library. Make sure it returns true so the button appears.
Any additional code in that function will run. You can also use Xrm.Page to grab what entity you are on, so it performs code where you want it to.