I found this handy bookmarklet for automatically logging into a website:
javascript:
document.body.appendChild(document.createElement('div')).innerHTML='
<form name="BletForm" method="POST" action="https://www.site.com/login">
<input type="hidden" name="_method" value="POST" />
<input type="hidden" name="data[User] [email]" value="someone@domain.com" />
<input type="hidden" name="data[User] [password]" value="password"/>
</form>';
document.forms['BletForm'].submit();
and I want to put it before the Stumble This! Bookmarklet (or any other Add to… bookmarklet)
javascript:document.location.href='http://www.stumbleupon.com/submit?url='+document.URL+'&title='+document.title.replace(/%20/g,'+');
In effect, I want to be able to save bookmarks straight away, without worrying about logging in first.
How would I do this?
Also, is it possible to specify more “automated steps” after the autologin bookmarklet? For instance once it fills in user, passwords, and submits the form, configure it to go to a specific URL (navigate inside the website you logged into).
Thanks!
Simply combining those two bookmarklets is not possible as a bookmarklet.
The reason is that you use must “Stumble This! Bookmarklet (or any other Add to… bookmarklet)” on the page you want to add, but you must use the login bookmarklet (or one similar to it) on the login page of the other site.
Because of cross domain security restrictions implemented by browsers, this is not possible to do in a single bookmarklet. You can not interact with a page from one site using code that is running on the page from a different site.
There is another solution, but it is not advised. If you want to add site A to site B, you could create a login form for site B on site A, and then submit it. That would log you into site B. After a reasonable time waiting for login to complete, it could then run the “add to” code. (To prevent a page navigation, the form target should be a new window or an iframe.)
Doing that is fairly complex, is a security risk, creates timing problems, and will force you to login every time, even if you are already logged in. Also, for some websites, it may be impossible if those website (wisely) use form key tokens to prevent cross site form submissions.
The only really viable solution is to create or use an add-ons or userscript.