How to click cancel in the prompt window?

I am developing a chrome extension to suppress a prompt box. Access is secured on the server side and the user is started with a prompt for username / password as shown below,

query window

I am inserting content_script into url in document_start and am trying to detect the presence of this prompt if I need to click Cancel. Here is a test link to get the login prompt, http://128.199.223.179/testing/test.php

+3


source to share


1 answer


Technically you cannot close the prompt with just the javascript api ... You may need to use an NPAPI plugin or other external software like Selenium to emulate a click on the close button.

But what you can do is prevent this dialog from appearing in the first place by intercepting the authentication request.

First add the "webRequest" permission to your manifest. Then try this code:



// to listen to all urls use { urls: ["<all_urls>"] }
chrome.webRequest.onAuthRequired.addListener(function(details) {
  return {cancel: true};
}, {urls: ["http://128.199.223.179/testing/test.php"]}, ["blocking"]);

      

For better documentation visit https://developer.chrome.com/extensions/webRequest#event-onAuthRequired

+1


source







All Articles