// ==UserScript== // @name Show Flickr NSID // @namespace http://www.dopiaza.org/flickr/greasemonkey/ // @description Display user's NSID // @include http://www.flickr.com/* // @include http://flickr.com/* // ==/UserScript== var imgElements = document.getElementsByTagName('img'); var buddyIconPattern = /^http:\/\/static.flickr.com\/\d+\/buddyicons\/(.+).jpg/; var blockheadPattern = /^http:\/\/www.flickr.com\/images\/buddyicon.jpg\?(.+)$/; for (var i = 0; i < imgElements.length; i++) { var img = imgElements[i]; var imgClass = img.getAttribute('class'); if (imgClass == 'person_hover_img') { // Just ignore this one - it's used when you hover over an user's icon continue; } // Check to see if this is a buddy icon image var src = img.getAttribute('src'); var result = buddyIconPattern.exec(src); if (result == null) { // Try the second version, just in case they have no buddy icon set result = blockheadPattern.exec(src); } if (result != null) { var nsid = result[1]; // We want the first containing tag that isn't an tag var container = img.parentNode; while (container.nodeName != null && container.nodeName == 'A') { container = container.parentNode; } var node = document.createElement('span'); node.appendChild(document.createTextNode(nsid)); node.style.fontSize = 'xx-small'; node.style.color = 'grey'; container.appendChild(node); } }