topical media & game development
mashup-flickr-09-Exercise-1-addcandymenus.user.js / js
// ==UserScript==
// @name Add Candy Menus
// @namespace http://www.dopiaza.org/flickr/greasemonkey/addcandy/
// @description Add a variety of menus to Flickr's navigation
// @include http://www.flickr.com/*
// @include http://flickr.com/*
// ==/UserScript==
function addCandy(menuId, text, link)
{
// Find the menu
var menus = document.evaluate(
"//div[@id='" + menuId + "']",
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
if (menus.snapshotLength > 0)
{
var menu = menus.snapshotItem(0);
var a = document.createElement('a');
a.setAttribute("href", link);
a.setAttribute("title", text);
a.appendChild(document.createTextNode(text));
menu.appendChild(a);
}
}
// The ids of the different menus are:
// candy_nav_button_you
// candy_nav_button_organize
// candy_nav_button_contacts
// candy_nav_button_groups
// candy_nav_button_explore
addCandy("candy_nav_menu_groups", "Forums", "http://www.flickr.com/forums/");
addCandy("candy_nav_menu_groups", "Utata", "http://www.flickr.com/groups/utata/");
addCandy("candy_nav_menu_explore", "API Reference", "http://www.flickr.com/services/api/");
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.