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 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.
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=".
var i = str.indexOf("hm___action=", 0);
if (i != -1)
{
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.
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
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.
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.