Feb 9 2005

Add A Bloglines Subscription From An IE Context Menu

Category: Rory Primrose @ 19:28

Now that I have been converted to Bloglines, I have noticed that they display details about a random feature that Bloglines supports when you log in. One of those features is a "Sub with Bloglines" link. They tell you to add that link to your favorites and whenever you want to subscribe to a page you are viewing, you go to your favorites menu and select the "Sub with Bloglines" link.

If you look at the URL behind that link, it is javascript:location.href='http://www.bloglines.com/sub/'+location.href. This is kind of like command line parameters for an application. If I provide a URL to http://www.bloglines.com/sub/, Bloglines will set up the subscription to that URL for me.

Personally, I don't like the idea of clicking on a favorites link to subscribe to something I am currently viewing, but it did give me a good idea. I know that you can create a registry entry that will add a menu item to the IE context menu . This registry entry will set when the context menu item should be displayed and what application to run when the menu item is selected.

In this case, I want the menu item displayed in the menu when an A tag is involved (context registry value) and I want IE to shell an HTML file (default registry value). That file simply has a script that calls Bloglines with the URL.

The registry file to register this extension is this:

 

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\Subscribe in Bloglines]

@="file://D:\\Program Files\\BrowserExt\\SubscribeBloglines.htm"

"contexts"=dword:00000022

 

BTW, change the folder path in the default registry value to the folder you have saved the HTML file into.

This is the HTML code:

<SCRIPT LANGUAGE="JavaScript" defer>
 
var objWin = external.menuArguments;
var objElement = FindLink(objWin.event.srcElement);
 
if (objElement != null)
{
    window.open("http://www.bloglines.com/sub/" + objElement.href);
}
 
function FindLink(objElement)
{
    if ((objElement != null)
        && (objElement != objWin.document.body))
    {
        if ((objElement.tagName != null)
            && (objElement.tagName.toUpperCase() == "A"))
        {
            return objElement;
        }
        else if (objElement.parentElement != null)
        {
            return FindLink(objElement.parentElement);
        }
    }
 
    return null;
}

</SCRIPT>

Cool eh?

Tags:

Comments (1) -

1.
Rory Primrose Rory Primrose says:

This code could also be implemented in a slightly different way.

Currently, the contexts registry value limits the context menu to display only when an A tag is found. You may want to change this to 1 instead of 22 so that it is always displayed, then change the script to use objWin.document.location.href if an A tag isn't found. This might suit some people more because Bloglines will attempt to find the most appropriate feed link url in the page if a page is specified instead of an RSS link.

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading