Carl is right. Why are you trying to modify the URL after the user receives the email?
If it helps any, here's one way to accomplish what you may be looking for if you can perform the logic before submission of email.
Could also perform 1 email activity after exiting the conditional statement and just use the branches to set variables to be included in the standard email.
// Your JS here