Your script is a bit unclear. Clients should automatically request proxy credentials when HTTP/407 received, although many do not .
If your question is: "How do I add a Proxy-Authorization header to all requests that go through Fiddler?" then it's pretty simple.
Rules> Configure Rules> Scroll to OnBeforeRequest and add:
if (!oSession.isHTTPS) { oSession.oRequest["Proxy-Authorization"] = "Basic dXNlcm5hbWU6cGFzc3dvcmQ="; }
Where dXNlcm5hbWU6cGFzc3dvcmQ= is the base64 encoded version of the username: password string. You can use Fiddler Tools> TextWizard to base64-encode a string.
source share