views:

38

answers:

2

I've been trying to figure out how to write a greasemonkey script to log me into a 401 html page. When I'm asked for a username and password in a pop up box (401 Request I believe), i want it to automatically log me in (my company's design sites are all the same username and password).

Any help?

Also, save passwords won't work because I'm dealing with new websites everyday (probably go to 1-2 new design sites a day.)

+3  A: 

I don't believe this is possible, not with GreaseMoney at least. It has no way to check the returned HTTP status code unless you make a request through it's xmlhttpRequest function. And if you're going to new sites everyday, then how is it suppose to know which ones it's suppose to log you into? Sending your username and password to any site that asks for authentication is a bad idea.

-Edit-

If you really want to do this, I think I may have thought of a way, albeit sloppy. Setup a custom page for 401 responses. Add some sort of special text to that page that you wouldn't expect to find anywhere else on the internet. Then have GreaseMonkey look for that text. If it finds it, redirect to the same URL, but add username:password@ in front of it.

So,

http://www.example.com/secret/dir/

becomes

http://user:[email protected]/secret/dir/

Then, when you're asked for your username and password, just click cancel.

Once again, I wouldn't really recommend this because if someone were to figure out why that weird super special text is in the page, they could trick you into doing this on their site and they would get your username and password.

Arctic Fire
this is the correct answer I believe.
Erik Vold
Thanks, I'll look into this later this afternoon when I have some free time.The security isn't an issue. All I would do is only apply it to design-mycompany.com . It's also not a top secret password. We give the same username and password out to our clients so this is more to keep it away from the masses.
Caleb Kester
A: 

You'd have to use a FF extension to achieve what you want..

Erik Vold