According to the man page, you can automatically  log into a proxy.  Perhaps you can bend that to your will.  See the "-pauth" argument in the man page.   I'm skeptical that it will do what you wish, but it's worth a shot.