May 15, 2011, 2:22 p.m.
posted by neverloop
Add a Feed to My Yahoo! with a Right-Click
Adding an RSS feed to My Yahoo! isn't a complex process, but it does involve some copying, pasting, clicking, and generally breaking out of the flow of reading a site. With a bit of browser hacking, you can reduce the friction of adding sites to My Yahoo! by adding a context menu entry.
A context menu is the menu that pops up when you right-click an element on a web page (or Ctrl-click it on a Mac). The context part of its name refers to the fact that different choices appear in different situations. For example, when you right-click a link, you have the options to "Open Link in New Window," Copy Link Location, Bookmark This Link, and others. In another context, such as when clicking an image or clicking highlighted text, you have different choices in the menu.
If you've been reading personal weblogs for a while, you've probably seen many variations of the white-on-orange XML buttons that indicate a link to an RSS feed, and if not you can find some examples [Hack #35] in this book.
Wouldn't it be great if you could right-click one of these buttons and have the option to "Add to My Yahoo!"? That would save you quite a few steps, and you wouldn't have to break from the site you're currently reading to add the feed. This hack shows how to add this context menu entry in Internet Explorer.
In this case, the action is grabbing the URL linked from the currently clicked image, constructing a special My Yahoo! URL that includes the feed URL, and opening the new URL in a new browser window.
Save the following code to a file called AddToMyYahoo.html:
The external.menuArguments object holds information about the current document, and the event.srcElement is the document item the user clicked. Grabbing the HRef attribute of the element's parent will give you the link URL that is around the image tag. Save the file in a spot you'll remember. For simplicity in this hack, save it to a directory called c:\scripts\.
Now that the script is ready to go, you just need to add the context menu entry to Internet Explorer and tell it to run this particular script when you click the entry. You'll accomplish this through the Windows Registry. The Registry is a system database that holds information about applications, including Internet Explorer. You can safely make additions to the Registry via .reg files. Create a new text file called AddYahooContext.reg and add the following code:
Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\Add to MyYahoo!] @="c:\\scripts\\AddToMyYahoo.html" "contexts"=dword:00000002
Note that the contexts entry here ends with 2, which means the entry will appear only when the user has clicked an image. Other values you could use here include 1 (for anywhere), 20 (for text links), or 10 (for text selections).
Save the file, double-click it, and confirm that you want to add the new Registry information. You'll now have a right-click menu entry called "Add to My Yahoo!" whenever you right-click an image.
Running the Hack
Once the code and Registry settings are in place, restart Internet Explorer. Browse to a site with a feed URL link and take the new context menu entry for a spin. When you right-click an image, you should see "Add to My Yahoo!," as shown in Figure.
When you click the "Add to My Yahoo!" menu entry, a window like the one shown in Figure should appear with the My Yahoo! feed preview page.
Keep in mind that the "Add to My Yahoo!" context menu entry will be available for every image on a web page, regardless of whether or not it links to an RSS feed. So you'll have to use your best judgment about when to use the feature. If the image turns out not to be linked to an RSS feed, the Yahoo! feed preview page will let you know quickly. If you don't see posts in the preview box on the right side of the page, you'll know that a feed won't be added to My Yahoo! if you click the Add button.