473,395 Members | 1,783 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Automatic Yahoo!mail or Gmail login by Javascript

Hi,

I'd like to write a HTML page which can help me directly log in my
Yahoo!mail or Gmail account without typing user name and password.
Basically, I want to set up a link, click it and pop up the Yahoo/Gmail
page.

What technology is most appropriate for this kind of work?

My current solution is not so satisfying: I download Yahoo!Mail page
and save it to local file; then using Javascript to load that file and
set up user name, password, submit it to Yahoo.

This works with Yahoo, but not Gmail. I haven't got time to investigate
why.

The thing I hate about this solution is: for every email provider, I
need to download their page and write corresponding page to
access/modify it.

Is there any better solution?

Your suggestion is highly appreciated!

Stan

Jul 23 '05 #1
12 22066
In article <11**********************@l41g2000cwc.googlegroups .com>, marmot101
@gmail.com enlightened us with...
I'd like to write a HTML page which can help me directly log in my
Yahoo!mail or Gmail account without typing user name and password.
Basically, I want to set up a link, click it and pop up the Yahoo/Gmail
page.

What technology is most appropriate for this kind of work?
POP3. ;)

This works with Yahoo, but not Gmail. I haven't got time to investigate
why.
Google checks the referrer.
Set it (to google) and you're good to go. Probably. I don't have Gmail, but
this was an issue for Google Search for one of my apps.
Not very portable, though, as far as solutions go.

The thing I hate about this solution is: for every email provider, I
need to download their page and write corresponding page to
access/modify it.

Is there any better solution?


Not that I can see. They're all going to have different field names more than
likely and they will have different referrers (if they check), so any code
would have to use different names and values for the POST request anyway. And
some may verify other headers that you would have to duplicate. This was an
issue when I tried to putz around with MySpace.com.

You could play with Java for this (or any language that supports sending HTTP
POST requests), but it's probably more of a pain than it's worth.

--
--
~kaeli~
Profanity: the single language in which all programmers are
expert.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2
Ivo
"Stanley" asks

I'd like to write a HTML page which can help me directly log in my
Yahoo!mail or Gmail account without typing user name and password.
Basically, I want to set up a link, click it and pop up the Yahoo/Gmail
page.

What technology is most appropriate for this kind of work?


I have a bookmarklet to auto-fill some forms on pages I visit regularly
enough. something like the following, all on one line and in less than 508
characters if you use IE:

javascript:function(){
var a=document.forms[0].elements,i=a.length,j,k;
while(i--){
j=a[i], k=j.name;
if(location.host==='mail.yahoo.com'){
if(k==='login'){ j.value='myname'; }
else if(k==='passwd'){ j.value='mypassword'; }
}
else if(location.host==='gmail.google.com'){
if(k==='Email'){ j.value='myname'; }
else if(k==='Passwd'){ j.value='mypassword'; }
}
}
document.forms[0].submit();
}

Consider who can access the Favorites folder and read its contents, and
decide if it's safe with that in mind. Perhaps patience and the continuous
effort of repeated typings is the most appropriate after all.
--
Io


Jul 23 '05 #3
"Ivo" <no@thank.you> writes:
I have a bookmarklet to auto-fill some forms on pages I visit regularly
enough. something like the following, all on one line and in less than 508
characters if you use IE:


Cute idea. To make it as short as possible, it could be rewritten something
like:
---
javascript:(function(){
var k={
'mail.yahoo.com': [0,{login:'myname',passwd:'mypass'}],
'gmail.google.com':[0,{Email:'myname',passwd:'mypass'}]
}[location.host],
f=document.forms[k[0]],e=f.elements,i=e.length,v;
while(i--)if(v=k[1][e[i]])e[i].value=v;
f.submit();
})();
---
Remember to put on one line before using. It will give a Javascript
error if it is used on an incorrect page, but who cares :) When
spaces and line breaks are removed, it's ~260 bytes.

The format of the data literal is:
{ <hostname> : [ <form index>, { <fieldname>:<value> , ... } ] ,
... }
It allows for pages where the login form is not the first one, and
any amount of fields that need to be filled.

If passwords or usernames are really repeated, space can be saved by
assigning to a variable first, and reusing it in the data object.

(Yes, I think optimizing for space is *fun* :)
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #4
Ivo
"Lasse Reichstein Nielsen" wrote
"Ivo" writes:
I have a bookmarklet to auto-fill some forms on pages I visit regularly
enough. something like the following, all on one line and in less than
508 characters if you use IE:


Cute idea. To make it as short as possible, it could be rewritten
<snip>
f.submit();
})();
(Yes, I think optimizing for space is *fun* :)


Ah, fun! we should hear that more! It looks quite optimum indeed. WOuld you
perhaps also know a funny and short solution to prevent submission if k
didn't match, ie. the bookmarklet was activated on an unsuspecting page and
I don't want to submit any forms I haven't even seen first. I speak from
experience here, I have missed that feature from my bookmarklet several
times now.
Ch.
--
Ivo
Jul 23 '05 #5
"Ivo" <no@thank.you> writes:
Ah, fun! we should hear that more! It looks quite optimum indeed. WOuld you
perhaps also know a funny and short solution to prevent submission if k
didn't match, ie. the bookmarklet was activated on an unsuspecting page and
I don't want to submit any forms I haven't even seen first.


Hmm. That would mean making sure that the correctly named form
controls did exist. Should be possible. hmm.... (and a little more
optimizing :)

---
javascript:(function(k,f,n){
f=document.forms[k[0]];
for(n in k[1])f.elements[n].value=k[1][n];
f.submit();
})({
'mail.yahoo.com': [0,{login:'myname',passwd:'mypass'}],
'gmail.google.com':[0,{Email:'myname',passwd:'mypass'}]
}[location.host]);
---

Again, no error checking. If the form lacks a required field,
it becomes "undefined.value=k[n]" ... immediate exit :)

An error checking version (i.e., stopping but not throwing an error)
would be a little longer:
---
javascript:(function(k,f,e,n){
if(k&&(f=document.forms[k[0]])){
for(n in k[1])if(e=f.elements[n])e.value=k[1][n];else return;
f.submit();
}})({
'mail.yahoo.com': [0,{login:'myname',passwd:'mypass'}],
'gmail.google.com':[0,{Email:'myname',passwd:'mypass'}]
}[location.host]);
---

No guarantees, except it seems to be syntactically correct :)

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #6
Forgive my ignorance: how do you use bookmarklet?

1. Store it in Favorite
2. Go to page like: mail.yahoo.com
3. Click that bookmarklet link

I am a pretty lazy one :-) I'd prefer one-click to destination.

Is my understanding right?

Jul 23 '05 #7
There is another approach, besides the nice Ivo/Lasse thread,
that has worked for me. Use vbscript (IE write a LoginToGmail.vbs
script) to bring up a fresh (or latch onto a specific) copy of IE
on Windows. Then direct IE to the login page. Then, you can,
through VBScript's access to the DOM, fill out the relevant
login and password entries and get directly to the page you want.
Just to emphasize, it is the external VBScript that is doing this,
since it has the authority to access the DOM of the top level pages.

The advantage that this method has over the javascript
version is that you can go through a sequence of multiple
pages whereas the javascript version gets you at most
one page before you wind up in a different domain.

Csaba Gabor from Vienna

Stanley wrote:
Hi,

I'd like to write a HTML page which can help me directly log in my
Yahoo!mail or Gmail account without typing user name and password.
Basically, I want to set up a link, click it and pop up the Yahoo/Gmail
page.

What technology is most appropriate for this kind of work?

My current solution is not so satisfying: I download Yahoo!Mail page
and save it to local file; then using Javascript to load that file and
set up user name, password, submit it to Yahoo.

This works with Yahoo, but not Gmail. I haven't got time to investigate
why.

The thing I hate about this solution is: for every email provider, I
need to download their page and write corresponding page to
access/modify it.

Is there any better solution?

Your suggestion is highly appreciated!

Stan

Jul 23 '05 #8
"Stanley" <ma*******@gmail.com> writes:
Forgive my ignorance: how do you use bookmarklet?

1. Store it in Favorite
2. Go to page like: mail.yahoo.com
3. Click that bookmarklet link
Yep.
I am a pretty lazy one :-) I'd prefer one-click to destination.


That's harder because of browsers' security settings not allowing
cross-domain scripting. The click that loads the page happens on
a page from another domain (pretty likely), and the same code
is not allowed to affect the new page.
You could probably do something with Opera 8's user.js, where you
pre-fill-out forms as soon as they are loaded (but then again, you can
just use a form-filler built into, or available as plugin to, most
browsers)

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #9
Csaba Gabor wrote:
There is another approach, besides the nice Ivo/Lasse
thread, that has worked for me. Use vbscript (IE write
a LoginToGmail.vbs script) to bring up a fresh (or latch
onto a specific) copy of IE on Windows. ...

<snip>

WSH can open the IE browser component, and then freely script it in
JScript or VBScript (and some others) without cross-domain security
restricitons.

Incidentally, Csaba, if you continue to top-post here you are unlikely
to get as much help here yourself as you have in the past.

Richard.
Jul 23 '05 #10
That's a method I'd like to try out. Thanks for suggestion, Csaba!

Jul 23 '05 #11
Richard Cornford wrote:
Csaba Gabor wrote:

WSH can open the IE browser component, and then freely script it in
JScript or VBScript (and some others) without cross-domain security
restricitons.
This isn't quite true, is it? If I bring up an instance of IE (via
WSH/VBScript) and go to a page which has an embedded I/Frame with a
different domain, then I can't gain access (from the calling .wsh or
..vbs file - at least this was my experience with VBScript on Win 2K
Pro / IE 5.5 two years ago) to that embedded domain's DOM using
traditional script methods . The original version of IE 5.5 did
allow the containing page to access the contained DOM (which is why I
never patched that machine!), but that was a security flaw which was
patched.
Incidentally, Csaba, if you continue to top-post here you are unlikely
to get as much help here yourself as you have in the past.


I would regret not having responses from you, Richard, since I consider
you one of the most reasoned, in depth persons in the groups I've been
in. But my actions are considered. If I am soliciting responses or
responding to someone who is responding to me, then I follow current
convention; or rather, I tend to reply with the convention of the responder
(usually bottom posting for single response, or interspersed for multiple
responses).

However, I believe this convention of bottom posting rests on flawed
principles, and that it will eventually be retired. So if I am a
primary respondent, offering advice or a suggestion, I will respond
in the manner of my choosing. The manner of my choosing is usually
dictated by what is most efficient for me, not only in responding
but for future reference (google is my filing cabinet). Since
bottom posting, as a general rule, is not nearly as efficient as top
posting * for me * I may top post for a single response or intersperse
for multiple responses). Increasingly, most of the time when I top
post, I will make a summary of what I am responding to (ie. I
usually respond with complete sentences for the sake of efficiency
and for all).

Csaba Gabor from Vienna
Jul 23 '05 #12
Csaba Gabor wrote:
Richard Cornford wrote: <snip>
Incidentally, Csaba, if you continue to top-post
here you are unlikely to get as much help here
yourself as you have in the past.

<snip> However, I believe this convention of bottom posting rests
on flawed principles, and that it will eventually be retired.
The convention is not bottom posting, it is interleaved posting with
responses under quoted sections that are being responded to and provide
a context for those response. And it isn't going to die out because it
is the form of communication best suited to the medium, which
considerate newcomers tend to rapidly realise.

<snip> ... , I will respond in the manner of my choosing.
The manner of my choosing is usually
dictated by what is most efficient for me, ...
* for me * I ... I ... I ... I ... I ...

<snip>

In a medium that is intrinsically one-to-many communication personal
preference is not necessarily a good guide to behaviour.

But suite yourself, not lifting a finger to provide you with any
assistance requires no effort on my part, but you might be a bit
cautious about encouraging others to shoot themselves in the foot as
well.

Richard.
Jul 23 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Terry | last post by:
I'm trying to automatically submit a form to another ASP page after some <input> fields values are filled by ASP. I know I can do it using javascript, but is there a way to automatically submit...
7
by: Lynn | last post by:
I'm running Oracle 8.1.7.4.1 on W2K and have the services for my oracle instances set to automatically startup and shutdown with the W2K server. Unfortunately, neither is working. Nothing gets...
9
by: Bryan Bullard | last post by:
#include <cstring> #include <iostream> #include <string> std::string foo() { char buf; strcpy(buf, "this is a test.");
1
by: raqfg | last post by:
Hi. I am trying to test out the automatic maintanance with notification feature of DB2 v8.2. I have enabled the auto maint with notification. The problem I am facing is that I only get email...
6
by: Gert van der Kooij | last post by:
Hi, It's no problem to define the automatic maintenance using the wizard but I want to use commands to automate automation. I captured the SQL statements when activating the maintenance but that...
2
by: Vaughn | last post by:
Where can I get information on automatic resizing of controls when the form changes size (eg. if I dynamically increase the size of my form, the listview inside should automatically increase in...
1
by: RK | last post by:
Hi Is there any way can we start the windows service after installation without the need for starting the service manually. I have StartType property set to "Automatic" for the service, but that...
1
by: Michel Esber | last post by:
Hello, Linux RedHat AS4 running DB2 V8 FP11. I have followed the docs at http://tinyurl.com/qckrn and enabled automatic statistics collection. It has been 2 days since I updated my DB cfg and...
3
by: schouwla | last post by:
Hi, I am a c# newbies.. I am having some problems with my dll it sometimes get's added to my cache even I don't want it to land there. My assembly is added to the cache here: C:\Documents...
6
by: JoshforRefugee | last post by:
heard that we can do automatic code generation using macros, but not sure how can I pursue this. Here is my problem. In my env, I have class A,B and C. All of them has constructors, and few...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.