Original source: https://code.google.com/p/chromium/issues/detail?id=123150
Created
May 17, 2012 19:00
-
-
Save jxpx777/2720920 to your computer and use it in GitHub Desktop.
JSE: Chrome HTTP auth callback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var gPendingCallbacks = []; | |
| var bkg = chrome.extension.getBackgroundPage(); | |
| bkg.console.log("Listening") | |
| chrome.webRequest.onAuthRequired.addListener(handleAuthRequest, | |
| {urls: ["<all_urls>"]}, ["asyncBlocking"]); | |
| function processPendingCallbacks() { | |
| bkg.console.log("Calling back with credentials"); | |
| var callback = gPendingCallbacks.pop(); | |
| callback({authCredentials: {username: <your username>, | |
| password: <your password>}}); | |
| } | |
| function handleAuthRequest(details, callback) { | |
| gPendingCallbacks.push(callback); | |
| processPendingCallbacks(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "Basic HTTP Auth Extension", | |
| "version": "1.0", | |
| "description": "Send credentials to basic HTTP auth pages.", | |
| "browser_action": { | |
| "default_icon": "icon.png" | |
| }, | |
| "background": { | |
| "scripts": ["background.js"] | |
| }, | |
| "permissions": [ | |
| "webRequest", | |
| "webRequestBlocking", | |
| "tabs", | |
| "https://*/* | |
| "http://*/* | |
| ] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment