Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kool79/0edf4903071288c561c3897bab3fbf85 to your computer and use it in GitHub Desktop.
Save kool79/0edf4903071288c561c3897bab3fbf85 to your computer and use it in GitHub Desktop.
Chrome extension to automatically set the credentials.
To build the extension, update the username/password and zip `background.js` and `manifest.json` in a single archive.
var username = "my-username";
var password = "my-password";
chrome.webRequest.onAuthRequired.addListener(
function handler(details) {
if (username == null)
return {cancel: true};
var authCredentials = {username: username, password: username};
username = password = null;
return {authCredentials: authCredentials};
},
{urls: ["<all_urls>"]},
['blocking']
);
{
"manifest_version": 2,
"name": "Authentication for ...",
"version": "1.0.0",
"permissions": ["<all_urls>", "webRequest", "webRequestBlocking"],
"background": {
"scripts": ["background.js"]
}
}
@ianceicys
Copy link

I am trying to install this extension on Chrome 60 and it does not install successfully. I have the manifest.json file in the zip folder.
Manifest file is missing or unreadable.
"Could not load manifest."

@balrob
Copy link

balrob commented Oct 6, 2017

There's an error in the source.
background.js:10 " var authCredentials = {username: username, password: username};" uses the "username" var twice, one should be "password".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment