Click here to Skip to main content
15,885,873 members
Articles / Programming Languages / Javascript
Article

Bored by Hotmail?

Rate me:
Please Sign up or sign in to vote.
4.78/5 (66 votes)
26 Oct 20043 min read 147.9K   1K   38   43
A workaround to escape the "Your email message has been idle" when clicking a link in a hotmail message that has been displayed for more than five minutes
  • <a href="/KB/scripting/hotmailworkaround/hotmailworkaround_src.zip"="">Download source files - 1 Kb

Introduction

This idea came up because I was bored by Hotmail's standard behaviour.

Every month I get the newsletter from CodeProject. These emails are pretty lengthy and contains several links. I read them using hotmail in a browser. When I follow one link I study the article for some time(5 min) and then closes the window. Now I want to read the next link in the newsletter but Hotmail gives me a popup-window as seen above stating that "this link has become inactive".

This is wrong, the link is active. CodeProject has not removed it. You can get around this by hitting the Refresh button of the browser but it is very annoying! You don't get around the fact that hotmail replaces the original links in your messages with a URL to one of their servers taking the original link as parameter. This is suggesting that hotmail is logging what links you visit!!!

This is Freakin' Spyware behaviour to me!!!

The Hack

I searched around for away of extending the capabilities of Internet Explorer and I found this article describing a way to <a href="http: msdn.microsoft.com="" workshop="" browser="" overview="" overview.asp?frame="true#Controlling_the_Cont"">Control the Context Menus. Items can be added to the existing context menus of the WebBrowser Control by placing entries in the registry and linking these to URLs that execute script.

To add items to the standard WebBrowser Control context menus, create or open the following key:

HKEY_CURRENT_USER
        Software
            Microsoft
                Internet Explorer
                    MenuExt

Under this key, you create a key whose name contains the text you want displayed in the menu. The default value for this key contains the URL that will be executed. The key name can include the ampersand (&) character, which will cause the character immediately following the & to be underlined

The following registry entry adds an item with the title Open Hotmail Link to the WebBrowser Control context menu and executes the inline script contained in the file c:\hotmail.js.

HKEY_CURRENT_USER
        Software
            Microsoft
                Internet Explorer
                    MenuExt
                        Open Hotmail Link = "file:///c:/hotmail.js"
                        Contexts          = dword:0x20

The "Contexts" DWORD value specifies the context menus in which an item will appear. In this case 0x20 is corresponding to CONTEXT_MENU_ANCHOR, the menu item will only be visible when you right clicked a hyperlink.

Now we have a way of invoking a JavaScript file by right clicking the hyperlink in the hotmail message. Let us consider the format of the hyperlink and restructure it using JavaScript.

"javascript:OpenWin('http://64.4.18.250:80/cgi-bin/linkrd?
_lang=EN&lah=f785aa457196eab7084467d483648024&lat=1098364221
&hm___action=http%253a%252f%252fwww%252ecodeproject
%252ecom%252fjscript%252fhotmailworkaround%252easp
%253fmsg%253d953418%2523xx953418xx');"

The first three lines above is added by hotmail and not of interest to us. The fourth line however contains a parameter called hm___action which is set to the value of the link as it was intended by the person or machine that sent the email.

First we obtain the link that was clicked.

JavaScript
//Obtain the hyperlink clicked
var oSource = external.menuArguments.event.srcElement

var str = new String(oSource.href);

Now the link is scanned for the first occurrence of the string "hm___action=".

JavaScript
//find the index of "hm___action=" in string
var i = str.indexOf("hm___action=", 0);

//if "hm___action=" was found then ...
if (i != -1)
{

//Cut away stuff added by hotmail
str = str.substring(i + 12, str.length-3);

...

}

The indexOf method finds the location of "hm___action=" inside str and tells you where the substring starts. If the string doesn't contain the substring, indexOf returns -1. The index i is then advanced by twelve, which is the number of characters in the string "hm___action=". Since the data of interest is located between i and the end of the string, except the last three chracters, str.length-3, a simple call to the substring method is used to extract it.

The value of str in our example is now.

"http%253a%252f%252fwww%252ecodeproject%252ecom%252f
jscript%252fhotmailworkaround%252easp
%253fmsg%253d953418%2523xx953418xx"

The original link has been URL encoded so lets URL decode it.

JavaScript
str = unescape(str);

After this operation the link is now in its original state before Hotmail meddled with it and all we have to do is to open it in a new browser window

JavaScript
open(str);
Now you can invoke the JavaScript on any link, not just hotmail, but it will only work its magic if the parameter hm___action is found.

Install

In the downloads at top you will receive a zip archive containing two files.

  • hotmail.js
  • hotmail.reg

The hotmail.js should be placed in C: directory. The hotmail.reg should be run to add the correct key and values to the registry. Don't forget to close all browser windows before trying out the hack. I hope it can be off some help. I know the problem bugged the hell out of me.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Sweden Sweden
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralRe: for image anchors it fails Pin
Dommett27-May-04 6:51
Dommett27-May-04 6:51 
GeneralRe: for image anchors it fails Pin
aalo27-May-04 10:03
aalo27-May-04 10:03 
GeneralYou put an idea in my head! Pin
Peter Piksa18-Mar-04 1:53
Peter Piksa18-Mar-04 1:53 
GeneralRe: You put an idea in my head! Pin
aalo19-Mar-04 8:05
aalo19-Mar-04 8:05 
QuestionHow to display on the list of urls that are primetted. Pin
Member 33502218-Mar-04 0:04
Member 33502218-Mar-04 0:04 
AnswerRe: How to display on the list of urls that are primetted. Pin
aalo3-Jun-04 10:41
aalo3-Jun-04 10:41 
GeneralJoy! Pin
Jim Taylor17-Mar-04 22:06
Jim Taylor17-Mar-04 22:06 
QuestionOutlook Express? Pin
Anthony_Yio16-Mar-04 23:49
Anthony_Yio16-Mar-04 23:49 
AnswerRe: Outlook Express? Pin
aalo17-Mar-04 0:52
aalo17-Mar-04 0:52 
AnswerRe: Outlook Express? Pin
Bee Master29-Mar-04 21:07
Bee Master29-Mar-04 21:07 
GeneralNice Pin
567890123416-Mar-04 22:37
567890123416-Mar-04 22:37 
GeneralRe: Nice Pin
MeterMan26-Mar-04 9:25
MeterMan26-Mar-04 9:25 
GeneralCode Enhancement Pin
Steve Miller16-Mar-04 9:18
Steve Miller16-Mar-04 9:18 
GeneralRe: Code Enhancement Pin
aalo16-Mar-04 21:14
aalo16-Mar-04 21:14 
GeneralExcellent but... Pin
Rob Catterall16-Mar-04 0:38
Rob Catterall16-Mar-04 0:38 
GeneralRe: Excellent but... Pin
aalo16-Mar-04 2:27
aalo16-Mar-04 2:27 
GeneralGood post! Pin
Rocky Moore12-Mar-04 8:41
Rocky Moore12-Mar-04 8:41 
GeneralRe: Good post! Pin
Prakash Nadar12-Mar-04 23:10
Prakash Nadar12-Mar-04 23:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.