// ==UserScript== // @name Flickr Comment Highlighter // @namespace http://www.dopiaza.org/flickr/greasemonkey/ // @description Highlight Flickr Comments // @include http://www.flickr.com/* // @include http://flickr.com/* // ==/UserScript== var buddyIconPattern = /^http:\/\/static.flickr.com\/\d+\/buddyicons\/(.+).jpg/; var blockheadPattern = /^http:\/\/www.flickr.com\/images\/buddyicon.jpg\?(.+)$/; var myNsid = unsafeWindow.global_nsid; var commenters = document.evaluate( "//td[@class='Who']", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); for (var i = 0; i < commenters.snapshotLength; i++) { var isMyComment = false; var tdCommenter = commenters.snapshotItem(i); // We are looking for the buddy icon contained within var images = tdCommenter.getElementsByTagName('IMG'); for (var j = 0; j < images.length; j++) { var img = images[j]; var src = img.getAttribute('src'); var result = buddyIconPattern.exec(src); if (result == null) { // Try the second version, just in case you have no buddy icon set result = blockheadPattern.exec(src); } if (result != null) { // This is the buddy icon var nsid = result[1]; if (nsid == myNsid) { isMyComment = true; } break; } } if (isMyComment) { // Need to restyle the comment to highlight it. // The parent container is the table row, and contains the commenter details // and the comment itself var container = tdCommenter.parentNode; container.style.backgroundColor = '#EEEEEE'; } }