decembre

GM - Flickr - Flickr Commented On (HTTPS) - v.2.29 - Tweak 2025 EXCLUDE

Aug 17th, 2016 (edited)
3,851
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name           Flickr Commented On (HTTPS) - v.2.29 - Tweak 2026 for POOL SM groups_pool.gne? - TEST EXCULDE / FIX Blockind Firefox Error Popup
  3. // @description    Shows whether or not you have commented on a photo - OK TAMPERMONKEY (pb semicolon) - EXCLUDE FAV/ALB etc 2019
  4. // @icon           https://icons.duckduckgo.com/ip2/flickr.com.ico
  5. // @include        http://www.flickr.com/*
  6. // @match          http://www.flickr.com/*
  7.  
  8. // @include http*://*flickr.com/*
  9.  
  10. // @exclude https://www.flickr.com/photos/*/galleries/*
  11.  
  12. // 2025.01
  13. // @include https://www.flickr.com/path=*
  14.  
  15. // 2019
  16. // @exclude    http*://*flickr.com/photos/*/favorites*
  17. // @exclude    http*://*flickr.com/photos/*/favorites/*
  18. // @exclude    http*://*flickr.com/photos/*/albums*
  19. // @exclude    http*://*flickr.com/groups?view=tn
  20. // @exclude    http*://*flickr.com/groups?view=ls
  21.  
  22. // @version        2.29
  23. // @author         Brenton Cleeland (http://www.flickr.com/people/sesh00/)
  24. // @date           Jul 3, 2007
  25. // @modified       Jul 18, 2013
  26. // @contributor    Alesa Dam (http://www.flickr.com/people/alesadam/)
  27. // @contributor    Martin Heimburger (http://www.flickr.com/people/vispillo/)
  28. // @contributor    Bennie Hebbelynck (http://www.flickr.com/people/hebbervus/)
  29. // @icon           http://s3.amazonaws.com/uso_ss/icon/82360/large.png?1326790459
  30. // @downloadURL    https://userscripts.org/scripts/source/82360.user.js
  31. // @updateURL      https://userscripts.org/scripts/source/82360.meta.js
  32. // @run-at     document-end
  33. // @grant      GM_log
  34. // @grant      GM_addStyle
  35. // @grant      GM_xmlhttpRequest
  36. // ==/UserScript==
  37. //
  38. // Icon based on a Webdesigner Depot (http://www.webdesignerdepot.com/) icon from the Primo set. Downloaded from http://www.iconfinder.com/icondetails/40747/128/chat_comments_references_talk_icon
  39. //
  40. //
  41.  
  42. (function () {
  43. // shows the number of comments you left on the photo
  44. SHOW_COMMENT_COUNT=true;
  45.  
  46. var retrievingButtonImg = "data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%18%00%00%00%18%08%06%00%00%00%E0w%3D%F8%00%00%00%01sRGB%00%AE%CE%1C%E9%00%00%00%04gAMA%00%00%B1%8F%0B%FCa%05%00%00%00%20cHRM%00%00z%26%00%00%80%84%00%00%FA%00%00%00%80%E8%00%00u0%00%00%EA%60%00%00%3A%98%00%00%17p%9C%BAQ%3C%00%00%00%18tEXtSoftware%00Paint.NET%20v3.08er%9C%E1%00%00%01%B8IDATHK%EDTK%ABAa%14u%7F%A2%01%C5%84%92%09e%A4%94%81W%5E)%8F%89%01I%14%26%1E%09%11%C9%CC%C8%1F0%95%BC%9F%13%A5%A4%E5%EE%5D%E4r%CEu%DC%9B%EE%BDuw%9D%3A%F5%ED%B3%D6%DAk%AF%EF%BC%E1%BDd%AF%2C%22xe%C9%5E%09%CE%EE%FC%13%3Cr%E0%E7%2C%DA%EDv%C8%E7%F3p8%1C%B0%D9l%A2O*%95%C2r%B9%14%1DDt%82l6%8Bv%BB%8D%C3%E1%F0%A9%0B%DDn%17%E1pX%B4O%90%60%BF%DF%C3n%B7%E3x%3C%82%26%D9n%B7%D8l6X%ADVX%2C%16%98%CDf%98L%26%FCP%C5b1%0C%87CA!%82%04%04%16%0C%06%F9%03z_%AF%D7w%E0%A3%D1%88A%03%81%00%9CN'%FA%FD%FE%D7%08%08%9C%3C%26%E5%D3%E9%14%E3%F1%18g%F0%C1%60%00%8F%C7%C3%13X%2C%16%E9%04%D7%16%91%3D%F3%F9%FC%02%EE%F7%FB%E1%F5z%E1v%BB%D9%C6h4%8AV%AB%85H%24%02%A3%D1xG%F2p%C9%B4%87%EB%22%C5%9DN%87%03%40%C0%CDf%13%B9%5C%0E%B5Z%0D%3E%9F%0FZ%AD%F6C%BF(%C19%A6%A4%F2%1C%D3j%B5%CA%B1%25%F0L%26%83t%3A%8Dd2%89x%3C%8ED%22%81R%A9%C4%E7%0A%85%E2B%F2%D4E%A38Z%ADVV%5D%AF%D7Yu%A5Ra%92b%B1%C8%13%A8%D5ji%13%DC%9A%D9h4P.%97a6%9Ba2%99%600%18%A0%D7%EBYq%A1P%E0%9D(%95J%E9%3B%B8%EE%A4%FC%87B!%F4z%BD%3B%00%8DF%03%97%CB%05%9DN'x%17%9E%B2H(%87*%95%0Ar%B9%FCr%E9n%7B%BEM%F0%7B%FF%A6%8F%94I%3D%FF%FB%16%9D%00%89%06%23%97%2Bi%AE%7F%00%00%00%00IEND%AEB%60%82";
  47. var retrievingButtonTransparentImg = "data:image/png;base64," +
  48.     "iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A" +
  49.     "/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9wGBgg2JLgP+JQAAAHPSURBVEjH" +
  50.     "7ZU/i+pAFMVPhgdio6AggjaKWNlaKIrY29hpp73fJIgW9gEhhX4AsRBstLSJCUo6KwMGCyHG/L1b" +
  51.     "6Vv36a482Oa9PXCruZzf3LlzZzgiwneK4Zv1A/gPAL+eLZzPZ5pMJlAUBb7vPzVIp9Oo1WqIRqPc" +
  52.     "wwQiehiiKNJsNiPHcegzLZdL6vV617w/fB5WYFkWqaqKRqOBy+UCwzBARPB9/y4AoFgsQpZlaJqG" +
  53.     "ZDL52hGZpolQKATGGGzbvu3mI8D3ffA8D9M0YRjG3zX5vbHnefA87w7gOA7i8TgEQXi9ycFgEKfT" +
  54.     "Cb7vgzEG13VvhsPh8M48FoshlUrBNE10Oh0aDAbcl4BAIMBls1maz+eoVqtg7HehnuehUCjcIEQE" +
  55.     "XdeRyWRgmiba7TYJgnCDcM9e0+s1lWUZ15x8Po/VaoVSqQRN025H5rouGGOIRCKQJAmKomA8HnOf" +
  56.     "Ah6p3+/T4XBApVK564Wu6wiHw1BVFev1GqIofl3BR02nU7IsC4vFArZtw3VdOI6DRCKBXC6H7XYL" +
  57.     "SZIwGo24lyb5vY7HI202G5TLZfA8f2fQarWIMYbdbodut/v6JL8azWaT6vU67ff7h5PM/XyZ/z7g" +
  58.     "DW0ytGWUWU3+AAAAAElFTkSuQmCC";
  59. var commentedButtonImg = "data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%18%00%00%00%18%08%02%00%00%00o%15%AA%AF%00%00%00%04gAMA%00%00%B1%8F%0B%FCa%05%00%00%00%FFIDAT8Oc%FC%FF%FF%3F%03%05%E0%F7%FF%8F%0C%7F%18XY%D9%18%80%06Q%02%FE%FD%FF%F6%1F%84%FESj%10%DC%11%23%C8%A0%CF%DF~N%DAx1%BAsgD%FB%0EL%D4%BA%FC%F4%F3w_%B0F%0Ez%18%E5L%3D%F0%DFm%19.%04%94%CD%9F~%E8%F7%9F%BF%98f%A1%18%F4%FD%E7%EF%C8%8E%1D%FF%D3%B7%E11%ABz%C1%F1%DBO%DF%130%E8%F5%87o%F8%5D%04%B4%A0s%D5%D9%B3%B7_%D1%CB%20%A8%D7p%87%11%D0E%B5%8BN%DC%7CB%C8k%40%07w%AF%3E%0B%F4%DD%0D%86%02%CC%60%02%0AB%02%FB%E7%AF%3F%04%BC%06%94%86D%3F0%C8!q%3Fw%C7U%B8%89%40v%C9%EC%23%C4F%3F%9AUy%D3%0F%02%1D%024%22%B6k%D7%DA%23w%F0do%7Cy%0D%E8%91%99%DB%AE%C4%F7%EC%DEr%F2%3E%C1%12%02%A7A%2F%DE%7F%05%1A%B4%F7%FCc%82F%40%14%8C%A0%DCOd%88%10NG%C3%C8%20%00%86%F1%02%3D%CA%BE%AA%7D%00%00%00%00IEND%AEB%60%82";
  60. var commentedButtonTransparentImg = "data:image/png;base64," +
  61.     "iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A" +
  62.     "/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9wGBggwFb+LXygAAAFDSURBVEjH" +
  63.     "Y/z//z8DLQETA43BqAUDbwELNsEv33/9n7/7BsPJGy8Y/v7Dncp0FYQZktw1GSQEuRlxqWHElkxz" +
  64.     "px38P3njM4Kuy/WXYmBmYmLoSbVmYGFmYiQqiH78+vP/7ecfDAyKAgQtmLzxGQMPJyvDg5efiI+D" +
  65.     "L99/MwjzcjAw3P9AVBjzcbExfPr2exClIh5OVoa3n38QbcCXH78ZeDhZibeAg42F0UhZlCHXX4rh" +
  66.     "5q5TODXe3HWKIddfiuHT118MCmK8DCSlIlgyPX79OQNM2tVQliGp7yJczbwifYbrj98zFAcb4E2m" +
  67.     "DP///ycK500/+P8GQ8H/uTuu/o/t2vV/7ZE7/4nRx0hMcZ077eB/XUURhmPXnjOE2qoweJspMFKU" +
  68.     "k5HByw/f/jMwMDCoSPIzpHlqM5KaihhHK5xRCwa/BQCpjKvJw6UcSAAAAABJRU5ErkJggg==";
  69. var notCommentedButtonImg = "data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%18%00%00%00%18%08%06%00%00%00%E0w%3D%F8%00%00%00%01sRGB%00%AE%CE%1C%E9%00%00%00%04gAMA%00%00%B1%8F%0B%FCa%05%00%00%00%20cHRM%00%00z%26%00%00%80%84%00%00%FA%00%00%00%80%E8%00%00u0%00%00%EA%60%00%00%3A%98%00%00%17p%9C%BAQ%3C%00%00%00%18tEXtSoftware%00Paint.NET%20v3.08er%9C%E1%00%00%01FIDATHK%EDT%3D%8B%83%40%14%CC%FDq%0DZ%C746bc%91T6%01%0B%1B%C1%CA%CA%3F%60%E9G%8C%9A%C4%0F%84%80%22a%EE%9E%A0%C8%9D%9E%26%10%8E%83%0C%2C%AC%B0%3B%F3f%DEs%3F%F0%85%D5%2BA%02%AF%C4%EA%95%E4m%3Ao%81%B9%04%FE.%A2%DB%ED%06UU%B1%5E%AF%C10%CC%E4R%14%05%D7%EBu%D2%C8%A4%83%FD~%0F%C30%D04%CD%AF)X%96%85%EDv%3BynT%A0%AA*%B0%2C%8B%FB%FD%0ErR%14%05%F2%3CG%9A%A6%B8%5C.H%92%04Q%14%B5%8B%20I%12%82%20%18-dT%80%C86%9BM%7B%81%F6Y%96%FD%20%0F%C3%B0'%DD%EDvp%1C%E79%01%22%A7%8C%A9%F28%8Eq%3A%9D%D0%91%7B%9E%D7%92%3E%2C0%8C%88%E29%9F%CF%3D%F9%F1x%84%EF%FBp%5D%17%9D%80%2C%CB%FD%FE%BB%8D%D9%26S%1F%86%207DN%C2%84%AE%C9u%5D%2F%8F%88NvcJ%CD%EE%C6T%D3%B4%9E%A4%2CK%D0%B7(%8A%CF%8D%E9X94%8E%E4%80%889%8E%83i%9As%3F%F2%F2%C7N%D7u%1C%0E%07%F0%3C%DF%C6%B2%14%8B%9E%0A%9A%7FA%10%60%DB%F6R%DE%FE%DC%22%81%87Y%07%17%DE%02%B3%E9%FD%FF%88%3E%01Y%AF%5CU%DDg(%08%00%00%00%00IEND%AEB%60%82";
  70. var notCommentedButtonTransparentImg = "data:image/png;base64," +
  71.     "iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A" +
  72.     "/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9wGBggUJWi6jiIAAAFtSURBVEjH" +
  73.     "7VUxisJQEH3/syBBUMHGwsrCG9gELLQO2OY8XiCn8ASCWAjBQi9gRLCzs1ALTdQombdVXN2Nuwax" +
  74.     "Wh8MDPz582bmz59RJPFKaLwYb4J/QPBx72C/37PX62E6nUJE7jqoVCqwLAvFYlElGpBMlE6nw8Fg" +
  75.     "wPP5zN8wGo3oOE5s98NPYgZhGHI+n8O2bRyPRwRBAJIQkRsBANM04XkelsslyuXyYyU6HA7I5XLQ" +
  76.     "WuN0Ol2i+U4Qk2SzWQRBkO4NrksoIiCJKIou+jVB6i4yDAPb7RYiAq01ROTiPNajKLrJ2DCMxzPI" +
  77.     "ZDKqWq3SdV00Gg1o/RXHer2G7/soFArI5/MYj8fwfR+lUimRQN2bpnGbep6H2KZWq8GyLADAbrfD" +
  78.     "cDjEYrGAbdvp2zRJHMfharVit9tlu92m67r86456dB/0+32GYYjJZIJmswnTNNVTP/kam82Gs9kM" +
  79.     "9XodrVZLpRkV6r3R3gRP4xMAelzWTzapqAAAAABJRU5ErkJggg==";
  80. var errorCommentedButtonImg = 'data:image/png;base64,' +
  81.     'iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sCDgYMGJVmyfcAAAF7SURBVEjH7VWxSwJRHP5MQQ4ChyCMhhrCgmw6dXBsadKknE2aT1wraClwFzcJQ4lAUChxc/F/sEFyCKegjFIOXkfpr+kOT++Od4W0+G3vfe993+/3+H48BxERZogFzBhzg78Z5EURb6XSr3kAcJilKC+KiCWT2no5lZrid8Nhbb2Ry/EbTIoDAPt4R+F7CABYrdd14p/dLgDAX6vxPdFhOj0lDgDHLueU+DjOdrb4OlAUBXK5jGG/rzMAgK+XV91Ztfrbp0dkWm2+DhhjKPZ6cHo8OvFJjIsfVe7tp2gpkcDi2rpp9ar49sm5vZgKgoDBYIDRaIRqNmv5NJlWG4wxCILAb+B2u+Hz+XAVDGIvtm+Z84doFLIsw+v12p8DVdys+nEYRdS0A7viaifcBpNzoKLQbOAuFMJKPM49By6z9MiXF7rqC80GDq5vEAgEtL3nSkWXJqM5AFmgI0nUkSQ69W8a8r1ikVqRiClPRGRpQESWl3l4x/xP/neDH8cgWRmnYjhfAAAAAElFTkSuQmCC';
  82. var errorCommentedButtonTransparentImg = "data:image/png;base64," +
  83.     "iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A" +
  84.     "/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9wGBgg7C6Zwu4AAAAGKSURBVEjH" +
  85.     "7VWxSwJxGH2XghwEDkEYDTWEBdl0p4NjS5Mm5WzS0nLiWkFLgbu4SRhKBIFBiZuLf0BNNkgO4RSU" +
  86.     "UcrBJaVfSyd3p3f8rpAWH9zw493vve/7eB8/jogwTkxhzJgY/M0gKwj0WijQb3kA4MxSlBUEisTj" +
  87.     "g/NsIsEZ+fVgcHBeymQ4ZgOjOAAo72/IffUAAPPlMrTiH80mAMBXKnFMI9pOJofEAWDX6RgS1+Jw" +
  88.     "bYWYOuh2u7fy5aXQa7d1BgDw+fyi+1et/uLxAalana0DRVGEfKsFh9utEzdCK75TvLGfoplYDNML" +
  89.     "i6bVq+Kr+0f2Ysrz/F2n00G/38dVOm05mlStDkVRwPM8u4HL5RK9Xi9O/X5sRDYtF+k+HIYsy/B4" +
  90.     "PHu290AVN6tei1ERNe3ArvhPJ8RsYNwDFblqBdeBAOaiUeY9cJqkh5NPjklbfa5awdbZOURRVEdB" +
  91.     "T8WiLk2j9gBEZPo1JIkakkQHvmUaxbfyeaqFQqY8EVkbEBGsLrPw3ORN/neDb7T6O9tyiYNeAAAA" +
  92.     "AElFTkSuQmCC";
  93.  
  94. if (typeof(GM_log) == "undefined") {
  95.     var GM_log = function(message) {
  96.         console.info('FCO: ' + message);
  97. };// semicolon
  98. }
  99.  
  100. // TWEAK TEST : document.getElementsByTagName('script')
  101. // OR:
  102. // document.getElementsByClassName("mystyle")[0].className;
  103. function addButtonToMenu(photo_id)
  104. {
  105.     var stats = document.getElementsByTagName('stats_ul');
  106.     if(stats) {
  107.     var libut = document.createElement('li');
  108.     libut.setAttribute('style','border-color:transparent;');
  109.     libut.setAttribute('class', 'stat-item');
  110.     var first = stats.getElementsByTagName('li')[0];
  111.     stats.insertBefore(libut, first);
  112.     var divbut = libut.appendChild(document.createElement('a'));
  113.     divbut.setAttribute('style','height:24px;');
  114.     var commentedButton = divbut.appendChild(document.createElement('img'));
  115.     commentedButton.setAttribute('style','position:relative; top:0px;');
  116.     commentedButton.id = 'FCO-image-' + photo_id;
  117.     commentedButton.alt = 'retrieving';
  118.     commentedButton.title = commentedButton.alt;
  119.     commentedButton.src = retrievingButtonImg;
  120.     }
  121.     return libut;
  122. }
  123.  
  124. function addButtonToImageCard(imgLinks,photo_id)
  125. {
  126.     if(imgLinks) {
  127.     var libut = document.createElement('li');
  128.     libut.setAttribute('style','border-color:transparent;');
  129.     libut.setAttribute('class', 'counter0');
  130.     var first = imgLinks.getElementsByTagName('li')[0];
  131.     imgLinks.insertBefore(libut, first);
  132.     var divbut = libut.appendChild(document.createElement('a'));
  133.     divbut.setAttribute('style','height:24px;');
  134.     var commentedButton = divbut.appendChild(document.createElement('img'));
  135.     commentedButton.setAttribute('style','position:relative; top:0px;');
  136.     commentedButton.id = 'FCO-image-' + photo_id;
  137.     commentedButton.alt = 'retrieving';
  138.     commentedButton.title = commentedButton.alt;
  139.     commentedButton.src = retrievingButtonImg;
  140.     }
  141.     return libut;
  142. }
  143.  
  144. function addButtonToThumbnail(thumbnail, photo_id, before) {
  145.     if ( document.getElementById('FCO-image-' + photo_id) ) { // there already is one (set page, apps page, ..)
  146.         return document.getElementById('FCO-image-' + photo_id);
  147.     }
  148.     if (!photo_id) {
  149.     photo_id = document.evaluate('./a/img', thumbnail, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).
  150.                 singleNodeValue.src.match(/.*flickr.com\/\d+\/(\d+)_.*/)[1];
  151.     }
  152.     var libut = document.createElement('div');
  153.         libut.setAttribute('style','display: inline-block; max-height: 16px; position: static;');
  154.     libut.setAttribute('id', 'FCO-photo-' + photo_id);
  155.     if (before) {
  156.         thumbnail.insertBefore(libut, before);
  157.     } else {
  158.         thumbnail.appendChild(libut);
  159.     }
  160.     var divbut = libut.appendChild(document.createElement('a'));
  161.     divbut.setAttribute('style', 'height:24px');
  162.     divbut.href = "#";
  163.     var commentedButton = divbut.appendChild(document.createElement('img'));
  164.     commentedButton.setAttribute('style', 'height:24px;');
  165.     commentedButton.id = 'FCO-image-' + photo_id;
  166.     commentedButton.title = 'retrieving';
  167.     commentedButton.src = retrievingButtonImg;
  168.  
  169.      var photoUrl = document.evaluate('.//a', thumbnail, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).
  170.             singleNodeValue.href;
  171.     getPhotoComments(photo_id, photoUrl);
  172.  
  173.     return libut;
  174. }
  175.  
  176. function addButtonToPoolItem(thumbnail) {
  177.     var photo_id = thumbnail.getAttribute('data-photo-id');
  178.     var hover = document.evaluate('.//div[contains(@class,"hover-target")]', thumbnail, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  179.     var meta = document.evaluate('.//div[contains(@class,"meta")]', thumbnail, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  180.     meta.setAttribute('style', 'display: inline-block; vertical-align: top;');
  181.     addButtonToThumbnail(hover, photo_id, meta);
  182. }
  183.  
  184. GM_addStyle(".FCO-gradient { " +
  185.     "background: -webkit-gradient(radial, center center, 0, center center, 24, from(#bbbbbb), to(#ffffff)); " +
  186.     "background: -webkit-radial-gradient(#bbbbbb, #ffffff); " +
  187.     "background: -moz-radial-gradient(circle, #bbbbbb, #ffffff); " +
  188.     "}; ");
  189.  
  190. function addButtonToJustifiedPoolItem(thumbnail, photo_id) { // photo_id passed for stream items
  191.     if (!photo_id) {
  192.         photo_id = thumbnail.getAttribute('data-photo-id');
  193.     }
  194.     if ( document.getElementById('FCO-image-' + photo_id) ) { // there already is one (set page, apps page, ..)
  195.         return;
  196.     }
  197.     var libut = thumbnail.appendChild(document.createElement('div'));
  198.         libut.setAttribute('style','display: inline-block; height: 24px; position: absolute; left: 10px; top: 10px;');
  199.     libut.setAttribute('id', 'FCO-photo-' + photo_id);
  200.     var divbut = libut.appendChild(document.createElement('a'));
  201.         divbut.setAttribute('style', 'height:24px;');
  202.         divbut.href = "#";
  203.     var commentedButton = divbut.appendChild(document.createElement('img'));
  204.         commentedButton.setAttribute('style', 'height:24px;');
  205.     commentedButton.setAttribute('class', 'FCO-gradient');
  206.         commentedButton.id = 'FCO-image-' + photo_id;
  207.         commentedButton.title = 'retrieving';
  208.         commentedButton.src = retrievingButtonTransparentImg;
  209.  
  210.         var photoUrl = document.evaluate('.//span[contains(@class,"photo_container")]/a', thumbnail, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.href;
  211.     getPhotoComments(photo_id, photoUrl);
  212.  
  213.     return libut;
  214. }
  215.  
  216. function setCommented(commented, photo_id, href, comment_count)
  217. {
  218.     var commentedButton = document.getElementById('FCO-image-' + photo_id);
  219.     if (!commentedButton) {
  220.     return;
  221.     }
  222.     switch (commented) {
  223.         case 'yes':
  224.             commentedButton.src = commentedButton.className.match('FCO-gradient') ? commentedButtonTransparentImg : commentedButtonImg;
  225.             commentedButton.alt = "Yay! You've commented on this photo!";// semicolon
  226.         if (SHOW_COMMENT_COUNT) {
  227.             var countId = 'FCO-image-count-' + photo_id;
  228.             if (!document.getElementById(countId)) {
  229.                         var count = document.createElement('span');
  230.                 count.id = countId;
  231.                         count.setAttribute('style', "display:inline;z-index: 2; position: relative; left: -15px; top: -12px; font-size: 10px; color: white;padding: 0px;border-right:0;");
  232.                         count.innerHTML = comment_count;
  233.                         count.title = commentedButton.alt;
  234.                 commentedButton.parentNode.appendChild(count);
  235.             }
  236.                 }
  237.             break;
  238.         case 'no':
  239.             commentedButton.src = commentedButton.className.match('FCO-gradient') ? notCommentedButtonTransparentImg : notCommentedButtonImg;
  240.             commentedButton.alt = "Go ahead! Make my day! (by commenting)";
  241.         break;
  242.         case 'error':
  243.                 commentedButton.src = commentedButton.className.match('FCO-gradient') ? errorCommentedButtonTransparentImg : errorCommentedButtonImg;
  244.                 commentedButton.alt = "Error: " + comment_count;
  245.             break;
  246.         default:
  247.             commentedButton.src = commentedButton.className.match('FCO-gradient') ? errorCommentedButtonTransparentImg : errorCommentedButtonImg;
  248.             commentedButton.alt = "Error: " + commented;
  249.             break;
  250.     }
  251.     commentedButton.title = commentedButton.alt;
  252.     if (href == "#reply-box") { // when clicked, go to the reply-box, and set focus
  253.         commentedButton.style.cursor = 'pointer';
  254.         commentedButton.addEventListener('click', function (e) {
  255.             var textarea = document.getElementById('message');
  256.             textarea.focus();
  257.             textarea.setSelectionRange(0,0);
  258.         }, false);
  259.     } else {
  260.         commentedButton.parentNode.href = href;
  261.     }
  262. }
  263.  
  264. // DECEMBRE CORRECTION 2014 : https://www.flickr.com/groups/flickrhacks/discuss/72157645811287588/#comment72157648370481010
  265. function getUsername() {
  266. //  var buddyIcon = document.evaluate('.//a[contains(@class,"account")]/img[contains(@class,"gn-buddyicon")]', document, null,
  267. //          XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  268.  
  269.             var buddyIcon = document.evaluate('.//span[contains(@class,"account")]/img[contains(@class,"gn-buddyicon")]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  270.  
  271.     if (!buddyIcon) return null;
  272.     return buddyIcon.src.match(/flickr.com\/\d+\/buddyicons\/(\d+@\w\d{2})/)[1];
  273. }
  274.  
  275. // thanks to Vispillo (http://www.flickr.com/photos/31747528@N05/):
  276. var getJSVariable = function(regex) {
  277.                 // Thanks to Vispillo for this compact code
  278.                 var scripts = document.getElementsByTagName('script');
  279.         for (var i = 0; i < scripts.length; ++i) {
  280.                         var html = scripts[i].innerHTML;
  281.             try {
  282.                 return html.match(regex)[1];
  283.             } catch(e) {
  284.             }
  285.                 }
  286.                 return undefined;
  287. };// semicolon
  288. var api_key = getJSVariable(/[\"\']api_key[\"\'][ :]+[\"\']([^\"\']+)[\"\']/);
  289. var auth_hash = getJSVariable(/[\"\']auth_hash[\"\'][ :]+[\"\']([^\"\']+)[\"\']/);
  290.  
  291. function getPhotoComments(photo_id, commentHref)
  292. {
  293.  
  294. // HTTPS
  295.     GM_xmlhttpRequest({
  296.             method:"GET",
  297.             // use www.flickr.com to call the api (same servers :) ), to make it work in Chrome
  298.             url: "https://www.flickr.com/services/rest/?method=flickr.photos.comments.getList&api_key="+api_key+"&photo_id=" + photo_id + "&format=json&nojsoncallback=1&auth_hash="+auth_hash,
  299.             onload:function(details) {
  300.                 try{
  301.                     try {
  302.                         var data = JSON.parse(details.responseText);
  303.                     } catch (e) { // older versions of FF don't have JSON
  304.             try {
  305.                             data = eval( '(' + details.responseText + ')');
  306.             } catch (f) {
  307.                 GM_log("error parsing JSON data: " + e);
  308.                 GM_log("received from server for photo_id(" + photo_id + "): '" + details.responseText + "'");
  309.                 setCommented('error', photo_id, commentHref, e);
  310.                 return;
  311.             }
  312.                     }
  313.                     if (data.stat == 'ok') {
  314.                         var comments = data.comments.comment;
  315.                         var commented = false;
  316.             var comment_count = 0;
  317.             var permalink = undefined;
  318.                         if (comments) {
  319.                             comments.forEach(function(comment, idx) {
  320.                                 if (commented && !SHOW_COMMENT_COUNT) return;
  321.                                 if (comment.authorname == user_name || comment.author == user_name) {
  322.                                     commented = true;
  323.                     ++comment_count;
  324.                                     if (permalink == undefined) permalink = comment.permalink;
  325.                                 }
  326.                             });
  327.                         if (commented) {
  328.                         setCommented('yes', photo_id, permalink.replace('#comment', 'comment'), comment_count);
  329.                 } else {
  330.                         setCommented('no', photo_id, commentHref, comment_count);
  331.                     }
  332.                         } else {
  333.                             setCommented('no', photo_id, commentHref, comment_count);
  334.                         }
  335.                     } else {
  336.                         setCommented(data.code + " - " + data.message, photo_id, commentHref, comment_count);
  337.                     }
  338.                 } catch(e) {
  339.                     GM_log("error parsing API result: " + e);
  340.             GM_log("response received: " + details.responseText);
  341.             setCommented('error', photo_id, commentHref, e + ' - ' + details.responseText);
  342.                 }
  343.             },
  344.             onerror: function(details) {
  345.                 GM_log("error: " + details.statusText);
  346.         setCommented('error', photo_id, commentHref, details.statusText);
  347.             }
  348.     });
  349.  
  350. }
  351.  
  352. var user_name = getUsername();
  353. if(!user_name) {
  354.     GM_log("no user name found");
  355.     return;
  356. } else {
  357.     GM_log("running for user " + user_name);
  358. }
  359.  
  360.  
  361. // TEST not Working : TWEAK DECEMBRE : .new-comment-text
  362. // TEST 2018 -
  363. try {
  364. if (document.location.href.match(/.*flickr.com\/photos\/[^\/]+\/\d+/)) { // on photo page
  365.     // add a 'reply' name anchor to jump to on button click
  366.     var anchorInCommentForm = document.evaluate('//div[contains(@class,"add-comment-form")]//a', document, null,
  367. //      var anchorInCommentForm = document.evaluate('//div[contains(@class,"new-comment-text")]//a', document, null,
  368.         XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  369.     if (anchorInCommentForm) { // no comment form: no permission to comment
  370.         anchorInCommentForm.setAttribute('name', 'reply-box');
  371.     }
  372.     var photo_id = document.location.href.match(/.*flickr.com\/photos\/[^\/]+\/(\d+)/)[1];
  373.  
  374.     addButtonToMenu(photo_id);
  375.     getPhotoComments(photo_id, "#reply-box");
  376.  
  377. // TEST todo 20117 decembre    https://www.flickr.com/groups/58146428@N00/pool/54528939@N06/ // TEST GROUP JUSTIFIED == .photo-list-photo-view == TEST == or contains(@class,"photo-list-photo-view")
  378. // TEST todo 20117 decembre     https://www.flickr.com/photos/j_chambon/sets/72157632865244719 // SET (ALBUM) === .fluid a.overlay == TEST == or contains(@class,"fluid a.overlay")
  379.  
  380.     // [2025.01] DECEMBRE FIX POOL SM - NEW URL - https://www.flickr.com/groups_pool.gne?path=portrait_face&nsid=&page=&jump_to=&thumb=1
  381. } else if (document.location.href.match(/.*flickr.com\/groups\/[^\/]+\/?$/) ||// group start pages
  382.        document.location.href.match(/https:\/\/www\.flickr\.com\/groups_pool\.gne\?path=[^&]+&nsid=&page=&jump_to=&thumb=1/) || // match any path value for NEW pool sm url
  383.        document.location.href.match(/.*flickr.com\/groups\/[^\/]+\/pool/) ||// group pools
  384.        document.location.href.match(/.*flickr.com\/photos\/[^\/]+\/favorites/) ||// favorites pages
  385.        document.location.href.match(/.*flickr.com\/photos\/[^\/]+\/archives/) ||// archive pages
  386.        document.location.href.match(/.*flickr.com\/photos\/friends/)) {// friends
  387.  
  388.     var poolPhotos = document.evaluate('//div[contains(@class,"pool-photo") or contains(@class,"fave") or contains(@class,"photo-display-item")]',
  389.         document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  390.     if (poolPhotos.snapshotLength <= 0) {
  391.         GM_log("no photos found, aborting");
  392.     return;
  393.     }
  394.     var poolItemDecorator = addButtonToJustifiedPoolItem; // assume justified view
  395.     var squarePhotos = document.evaluate('count(//span[contains(@class,"pc_s")])', document, null,
  396.             XPathResult.ANY_TYPE, null);
  397.     if (squarePhotos.numberValue == poolPhotos.snapshotLength) {
  398.         // square thumbnails view
  399.     poolItemDecorator = null; // not on squares!
  400.     // except on set pages:
  401.     //if (document.location.href.match(/.*flickr.com\/photos\/[^\/]+\/sets/)) {
  402.         poolPhotos = document.evaluate('//span[contains(@class,"photo_container")]', document, null,
  403.                 XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  404.         poolItemDecorator = addButtonToThumbnail;
  405.     //}
  406.     } else {
  407.         var smallPhotos = document.evaluate('count(//span[contains(@class,"pc_t")])', document, null,
  408.         XPathResult.ANY_TYPE, null);
  409.     if (smallPhotos.numberValue == poolPhotos.snapshotLength) {
  410.         // small thumbnails view
  411.         poolItemDecorator = addButtonToPoolItem;
  412.     } else {
  413.         var mediumPhotos = document.evaluate('count(//span[contains(@class,"pc_m")])', document, null,
  414.             XPathResult.ANY_TYPE, null);
  415.         if (mediumPhotos.numberValue == poolPhotos.snapshotLength) {
  416.             // medium view
  417.             poolItemDecorator = addButtonToPoolItem;
  418.         } else {
  419.             var largePhotos = document.evaluate('count(//span[contains(@class,"pc_z")])', document, null,
  420.                 XPathResult.ANY_TYPE, null);
  421.             if (largePhotos.numberValue == poolPhotos.snapshotLength) {
  422.                 // large view
  423.                 poolItemDecorator = addButtonToPoolItem;
  424.             } else {
  425.                 //alert("justified view (" + poolPhotos.snapshotLength + ")");
  426.             }
  427.         }
  428.     }
  429.     }
  430.  
  431.     if (!poolItemDecorator) {
  432.     return;
  433.     }
  434.  
  435.     for (var i = 0, len = poolPhotos.snapshotLength; i < len; ++i) {
  436.         var thumbnail = poolPhotos.snapshotItem(i);
  437.     poolItemDecorator(thumbnail);
  438.     }
  439.     document.getElementById('main').addEventListener('DOMNodeInserted', function(event) {
  440.         setTimeout(function() { // workaround: addEventListener callback gets called in unsafeWindow!
  441.             try {
  442.                     var target = event.target;
  443.                     if (target.nodeName == 'DIV' && (target.className.match('pool-photo') || target.className.match('fave') || target.className.match('photo-display-item'))) {
  444.                 poolItemDecorator(target);
  445.                     }
  446.             } catch (e) {
  447.                     GM_log("error on insert: " + e);
  448.             }
  449.     }, 0);
  450.     }, true);
  451. } else if (document.location.href.match(/.*flickr.com\/photosof\/contacts/) ||// contacts
  452.            document.location.href.match(/.*flickr.com\/activity/)) {// recent activity
  453.     var poolThumbnails = document.evaluate('//span[contains(@class,"photo_container")]', document, null,
  454.         XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  455.     for (var i = 0, len = poolThumbnails.snapshotLength; i < len; ++i) {
  456.         var thumbnail = poolThumbnails.snapshotItem(i);
  457.         try {
  458.             var photo_id = document.evaluate('./a/img', thumbnail, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).
  459.                 singleNodeValue.src.match(/.*flickr.com\/\d+\/(\d+)_.*/)[1];
  460.         } catch (e) {
  461.             continue;
  462.         }
  463.         var commentedOnButton = addButtonToThumbnail(thumbnail, photo_id);
  464.         try {
  465.             // move the balloon
  466.             thumbnail.parentNode.insertBefore(commentedOnButton, thumbnail.nextSibling.nextSibling.nextSibling); // span - br
  467.         } catch (e) {
  468.             try {
  469.                 thumbnail.parentNode.insertBefore(commentedOnButton, thumbnail.nextSibling);
  470.             } catch (e) {
  471.                 GM_log("error inserting: " + e);
  472.             }
  473.             GM_log("error moving: " + e);
  474.             // ignore: let it be
  475.         }
  476.     }
  477. } else if (document.location.href.match(/.*flickr.com\/photos\/[^\/]+(\/page\d+|\/with\/\d+.*)?\/?$/) || // stream pages
  478.        document.location.href.match(/.*flickr.com\/photos\/[^\/]+\/sets/)) {// set pages
  479.     document.getElementById('main').addEventListener('DOMNodeInsertedIntoDocument', function(evt) {
  480.         setTimeout(function() { // workaround: addEventListener callback gets called in unsafeWindow!
  481.             try {
  482.                     var target = evt.target;
  483.                     if (target.nodeName == 'SPAN' && target.className.match("attribution")) {
  484.                 //unsafeWindow.console.log("add attribution");
  485.                 var thumbnailDiv = document.evaluate('.//ancestor::div[contains(@class,"photo-display-item")]', target, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  486.                 var photo_id = thumbnailDiv.getAttribute('data-photo-id');
  487.                 var thumbnail = document.evaluate('.//div[contains(@class,"thumb")]', thumbnailDiv, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  488.                 addButtonToJustifiedPoolItem(thumbnail, photo_id);
  489.                     } else if (target.nodeName == 'DIV' && target.className.match("cover-photo-position")) { // page has been reloaded: re-run
  490.                 //unsafeWindow.console.log("add buttons");
  491.                     var streamItems = document.evaluate('//div[contains(@class,"photo-display-item")]', document, null,
  492.                     XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  493.                     for (var i = 0, len = streamItems.snapshotLength; i < len; ++i) {
  494.                     var streamItem = streamItems.snapshotItem(i);
  495.                     var photo_id = streamItem.getAttribute('data-photo-id');
  496.                     var thumbnail = document.evaluate('.//div[contains(@class,"thumb")]', streamItem, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  497.                     addButtonToJustifiedPoolItem(thumbnail, photo_id);
  498.                     }
  499.             } else {
  500.                 //unsafeWindow.console.log("adding " + target.nodeName + "(class:" + target.className + ")");
  501.             }
  502.             } catch (e) {
  503.                     GM_log("error on insert: " + e);
  504.             }
  505.     }, 0);
  506.     }, true);
  507.         var streamItems = document.evaluate('//div[contains(@class,"photo-display-item")]', document, null,
  508.         XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  509.         for (var i = 0, len = streamItems.snapshotLength; i < len; ++i) {
  510.         var streamItem = streamItems.snapshotItem(i);
  511.         var photo_id = streamItem.getAttribute('data-photo-id');
  512.         var thumbnail = document.evaluate('.//div[contains(@class,"thumb")]', streamItem, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  513.         addButtonToJustifiedPoolItem(thumbnail, photo_id);
  514.         }
  515. } else if (document.location.href.match(/.*flickr.com\/?$/)) {// flickr home page
  516.     var imageItems = document.evaluate('//div[contains(@class,"imgWrapper")]', document, null,
  517.         XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  518.     for (var i = 0, len = imageItems.snapshotLength; i < len; ++i) {
  519.     var imageItem = imageItems.snapshotItem(i);
  520.     var photo_id = imageItem.getAttribute('data-photo-id');
  521.     var imgLinks = document.evaluate('.//ul[contains(@class,"imgLinks")]', imageItem, null,
  522.         XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  523.     addButtonToImageCard(imgLinks, photo_id);
  524.     var photoUrl = document.evaluate('.//a', imageItem, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).
  525.             singleNodeValue.href;
  526.     getPhotoComments(photo_id, photoUrl);
  527.     }
  528. }
  529.  
  530. } catch (e) { console.error('exception:', e); }
  531.  
  532. })();
  533.  
  534.  
Comments
  • decembre
    1 year (edited)
    Comment was deleted
  • decembre
    91 days (edited)
    Comment was deleted
Add Comment
Please, Sign In to add comment