// ==UserScript==
// @name           Flickr: Hide Comment Images
// @description	   Hide annoying comment images and awards on Flickr
// @author	   StuBramley & jciv
// @namespace      http://jciv.com/flickr/
// @include        http://*flickr.com/photos/*
// @include        http://*flickr.com/recent_activity.gne*
// @include        http://*flickr.com/photos_comments.gne*
// @version        1.1 01-Feb-2008
// ==/UserScript==

/*
Based on StuBramley's Remove Comment Images GreaseMonkey script with added XPATH rules by jciv for Recent Activity and Comments Pages.
A side effect is that it also blocks images that the original poster may include in comments as follow up or background photos. If you
find you are missing something temporarily disable Greasemonkey and reload the page.  The rules for Recent Activity and Comment Pages
need modification to work in languages other than English, replace 'says:' with the appropriate text.
*/

var XPATH_IMAGES_IN_COMMENTS = "//td[@class='Said']//img[@class!='ProIcon' or not(@class)]";                                             // gets images on photo pages
XPATH_IMAGES_IN_COMMENTS += "|//table[@class='NewComments']//tbody//tr//td[last()-1]//b[contains(.,'says:')]/following-sibling::*//img"; // gets most images on activity/comment pages
XPATH_IMAGES_IN_COMMENTS += "|//table[@class='NewComments']//tbody//tr//td[last()-1]//b[contains(.,'says:')]/following-sibling::img";    // gets the leftovers on activity/comment pages

function stripImagesInComments() {

   var listImages = document.evaluate(
            XPATH_IMAGES_IN_COMMENTS,
            document,
            null,
            XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
            null);    

   for (var i=0 ; i < listImages.snapshotLength; i++) {
     var imgNode = listImages.snapshotItem(i);
     imgNode.parentNode.removeChild(imgNode);  
   }
}

document.onBeforeLoad=stripImagesInComments();

