Remove bad, repeated code
Use regex for matching URLs
Load correct scripts for this branch