Generic URL to user billing page in Javascript not working

Isn’t that because users are never in /my/* URLs because they are just a smart redirect?

For example, /my/preferences will redirect me to /u/falco/preferences, so I’m never at the /my/preferences page for the if on your code to trigger.