decembre

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

Aug 17th, 2016 (edited)
3,872
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.  
  5. // BIG ENABLE
  6. // @icon           https://external-content.duckduckgo.com/ip3/blog.flickr.net.ico
  7.  
  8. // MATCH last 2026
  9. // @include        http://www.flickr.com/*
  10. // @match          http://www.flickr.com/*
  11. // @match          http*://*flickr.com/*
  12. // @match          https://www.flickr.com/path=*
  13. // @match          https://www.flickr.com/groups_pool.gne?*
  14.  
  15. // EXCLUDE last 2026
  16.  
  17. // @exclude        https://www.flickr.com/search/?*
  18. // @exclude        https://www.flickr.com/photos/*/galleries/*
  19. // @exclude        http*://*flickr.com/photos/*/favorites*
  20. // @exclude        http*://*flickr.com/photos/*/favorites/*
  21. // @exclude        http*://*flickr.com/photos/*/albums*
  22. // @exclude        http*://*flickr.com/groups?view=tn
  23. // @exclude        http*://*flickr.com/groups?view=ls
  24.  
  25. // @version        2.29
  26. // @author         Brenton Cleeland (http://www.flickr.com/people/sesh00/)
  27. // @date           Jul 3, 2007
  28. // @modified       Jul 18, 2013
  29. // @contributor    Alesa Dam (http://www.flickr.com/people/alesadam/)
  30. // @contributor    Martin Heimburger (http://www.flickr.com/people/vispillo/)
  31. // @contributor    Bennie Hebbelynck (http://www.flickr.com/people/hebbervus/)
  32. // @icon           http://s3.amazonaws.com/uso_ss/icon/82360/large.png?1326790459
  33. // @downloadURL    https://userscripts.org/scripts/source/82360.user.js
  34. // @updateURL      https://userscripts.org/scripts/source/82360.meta.js
  35. // @run-at     document-end
  36. // @grant      GM_log
  37. // @grant      GM_addStyle
  38. // @grant      GM_xmlhttpRequest
  39. // ==/UserScript==
  40. //
  41. // 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
  42. //
  43. //
  44.  
  45. (function () {
  46. // shows the number of comments you left on the photo
  47. SHOW_COMMENT_COUNT=true;
  48.  
  49. 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";
  50. var retrievingButtonTransparentImg = "data:image/png;base64," +
  51.     "iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A" +
  52.     "/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9wGBgg2JLgP+JQAAAHPSURBVEjH" +
  53.     "7ZU/i+pAFMVPhgdio6AggjaKWNlaKIrY29hpp73fJIgW9gEhhX4AsRBstLSJCUo6KwMGCyHG/L1b" +
  54.     "6Vv36a482Oa9PXCruZzf3LlzZzgiwneK4Zv1A/gPAL+eLZzPZ5pMJlAUBb7vPzVIp9Oo1WqIRqPc" +
  55.     "wwQiehiiKNJsNiPHcegzLZdL6vV617w/fB5WYFkWqaqKRqOBy+UCwzBARPB9/y4AoFgsQpZlaJqG" +
  56.     "ZDL52hGZpolQKATGGGzbvu3mI8D3ffA8D9M0YRjG3zX5vbHnefA87w7gOA7i8TgEQXi9ycFgEKfT" +
  57.     "Cb7vgzEG13VvhsPh8M48FoshlUrBNE10Oh0aDAbcl4BAIMBls1maz+eoVqtg7HehnuehUCjcIEQE" +
  58.     "XdeRyWRgmiba7TYJgnCDcM9e0+s1lWUZ15x8Po/VaoVSqQRN025H5rouGGOIRCKQJAmKomA8HnOf" +
  59.     "Ah6p3+/T4XBApVK564Wu6wiHw1BVFev1GqIofl3BR02nU7IsC4vFArZtw3VdOI6DRCKBXC6H7XYL" +
  60.     "SZIwGo24lyb5vY7HI202G5TLZfA8f2fQarWIMYbdbodut/v6JL8azWaT6vU67ff7h5PM/XyZ/z7g" +
  61.     "DW0ytGWUWU3+AAAAAElFTkSuQmCC";
  62. 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";
  63. var commentedButtonTransparentImg = "data:image/png;base64," +
  64.     "iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A" +
  65.     "/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9wGBggwFb+LXygAAAFDSURBVEjH" +
  66.     "Y/z//z8DLQETA43BqAUDbwELNsEv33/9n7/7BsPJGy8Y/v7Dncp0FYQZktw1GSQEuRlxqWHElkxz" +
  67.     "px38P3njM4Kuy/WXYmBmYmLoSbVmYGFmYiQqiH78+vP/7ecfDAyKAgQtmLzxGQMPJyvDg5efiI+D" +
  68.     "L99/MwjzcjAw3P9AVBjzcbExfPr2exClIh5OVoa3n38QbcCXH78ZeDhZibeAg42F0UhZlCHXX4rh" +
  69.     "5q5TODXe3HWKIddfiuHT118MCmK8DCSlIlgyPX79OQNM2tVQliGp7yJczbwifYbrj98zFAcb4E2m" +
  70.     "DP///ycK500/+P8GQ8H/uTuu/o/t2vV/7ZE7/4nRx0hMcZ077eB/XUURhmPXnjOE2qoweJspMFKU" +
  71.     "k5HByw/f/jMwMDCoSPIzpHlqM5KaihhHK5xRCwa/BQCpjKvJw6UcSAAAAABJRU5ErkJggg==";
  72. 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";
  73. var notCommentedButtonTransparentImg = "data:image/png;base64," +
  74.     "iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A" +
  75.     "/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9wGBggUJWi6jiIAAAFtSURBVEjH" +
  76.     "7VUxisJQEH3/syBBUMHGwsrCG9gELLQO2OY8XiCn8ASCWAjBQi9gRLCzs1ALTdQombdVXN2Nuwax" +
  77.     "Wh8MDPz582bmz59RJPFKaLwYb4J/QPBx72C/37PX62E6nUJE7jqoVCqwLAvFYlElGpBMlE6nw8Fg" +
  78.     "wPP5zN8wGo3oOE5s98NPYgZhGHI+n8O2bRyPRwRBAJIQkRsBANM04XkelsslyuXyYyU6HA7I5XLQ" +
  79.     "WuN0Ol2i+U4Qk2SzWQRBkO4NrksoIiCJKIou+jVB6i4yDAPb7RYiAq01ROTiPNajKLrJ2DCMxzPI" +
  80.     "ZDKqWq3SdV00Gg1o/RXHer2G7/soFArI5/MYj8fwfR+lUimRQN2bpnGbep6H2KZWq8GyLADAbrfD" +
  81.     "cDjEYrGAbdvp2zRJHMfharVit9tlu92m67r86456dB/0+32GYYjJZIJmswnTNNVTP/kam82Gs9kM" +
  82.     "9XodrVZLpRkV6r3R3gRP4xMAelzWTzapqAAAAABJRU5ErkJggg==";
  83. var errorCommentedButtonImg = 'data:image/png;base64,' +
  84.     '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';
  85. var errorCommentedButtonTransparentImg = "data:image/png;base64," +
  86.     "iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A" +
  87.     "/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9wGBgg7C6Zwu4AAAAGKSURBVEjH" +
  88.     "7VWxSwJxGH2XghwEDkEYDTWEBdl0p4NjS5Mm5WzS0nLiWkFLgbu4SRhKBIFBiZuLf0BNNkgO4RSU" +
  89.     "UcrBJaVfSyd3p3f8rpAWH9zw493vve/7eB8/jogwTkxhzJgY/M0gKwj0WijQb3kA4MxSlBUEisTj" +
  90.     "g/NsIsEZ+fVgcHBeymQ4ZgOjOAAo72/IffUAAPPlMrTiH80mAMBXKnFMI9pOJofEAWDX6RgS1+Jw" +
  91.     "bYWYOuh2u7fy5aXQa7d1BgDw+fyi+1et/uLxAalana0DRVGEfKsFh9utEzdCK75TvLGfoplYDNML" +
  92.     "i6bVq+Kr+0f2Ysrz/F2n00G/38dVOm05mlStDkVRwPM8u4HL5RK9Xi9O/X5sRDYtF+k+HIYsy/B4" +
  93.     "PHu290AVN6tei1ERNe3ArvhPJ8RsYNwDFblqBdeBAOaiUeY9cJqkh5NPjklbfa5awdbZOURRVEdB" +
  94.     "T8WiLk2j9gBEZPo1JIkakkQHvmUaxbfyeaqFQqY8EVkbEBGsLrPw3ORN/neDb7T6O9tyiYNeAAAA" +
  95.     "AElFTkSuQmCC";
  96.  
  97. if (typeof(GM_log) == "undefined") {
  98.     var GM_log = function(message) {
  99.         console.info('FCO: ' + message);
  100. };// semicolon
  101. }
  102.  
  103. // TWEAK TEST : document.getElementsByTagName('script')
  104. // OR:
  105. // document.getElementsByClassName("mystyle")[0].className;
  106. function addButtonToMenu(photo_id)
  107. {
  108.     var stats = document.getElementsByTagName('stats_ul');
  109.     if(stats) {
  110.     var libut = document.createElement('li');
  111.     libut.setAttribute('style','border-color:transparent;');
  112.     libut.setAttribute('class', 'stat-item');
  113.     var first = stats.getElementsByTagName('li')[0];
  114.     stats.insertBefore(libut, first);
  115.     var divbut = libut.appendChild(document.createElement('a'));
  116.     divbut.setAttribute('style','height:24px;');
  117.     var commentedButton = divbut.appendChild(document.createElement('img'));
  118.     commentedButton.setAttribute('style','position:relative; top:0px;');
  119.     commentedButton.id = 'FCO-image-' + photo_id;
  120.     commentedButton.alt = 'retrieving';
  121.     commentedButton.title = commentedButton.alt;
  122.     commentedButton.src = retrievingButtonImg;
  123.     }
  124.     return libut;
  125. }
  126.  
  127. function addButtonToImageCard(imgLinks,photo_id)
  128. {
  129.     if(imgLinks) {
  130.     var libut = document.createElement('li');
  131.     libut.setAttribute('style','border-color:transparent;');
  132.     libut.setAttribute('class', 'counter0');
  133.     var first = imgLinks.getElementsByTagName('li')[0];
  134.     imgLinks.insertBefore(libut, first);
  135.     var divbut = libut.appendChild(document.createElement('a'));
  136.     divbut.setAttribute('style','height:24px;');
  137.     var commentedButton = divbut.appendChild(document.createElement('img'));
  138.     commentedButton.setAttribute('style','position:relative; top:0px;');
  139.     commentedButton.id = 'FCO-image-' + photo_id;
  140.     commentedButton.alt = 'retrieving';
  141.     commentedButton.title = commentedButton.alt;
  142.     commentedButton.src = retrievingButtonImg;
  143.     }
  144.     return libut;
  145. }
  146.  
  147. function addButtonToThumbnail(thumbnail, photo_id, before) {
  148.     if ( document.getElementById('FCO-image-' + photo_id) ) { // there already is one (set page, apps page, ..)
  149.         return document.getElementById('FCO-image-' + photo_id);
  150.     }
  151.     if (!photo_id) {
  152.     photo_id = document.evaluate('./a/img', thumbnail, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).
  153.                 singleNodeValue.src.match(/.*flickr.com\/\d+\/(\d+)_.*/)[1];
  154.     }
  155.     var libut = document.createElement('div');
  156.         libut.setAttribute('style','display: inline-block; max-height: 16px; position: static;');
  157.     libut.setAttribute('id', 'FCO-photo-' + photo_id);
  158.     if (before) {
  159.         thumbnail.insertBefore(libut, before);
  160.     } else {
  161.         thumbnail.appendChild(libut);
  162.     }
  163.     var divbut = libut.appendChild(document.createElement('a'));
  164.     divbut.setAttribute('style', 'height:24px');
  165.     divbut.href = "#";
  166.     var commentedButton = divbut.appendChild(document.createElement('img'));
  167.     commentedButton.setAttribute('style', 'height:24px;');
  168.     commentedButton.id = 'FCO-image-' + photo_id;
  169.     commentedButton.title = 'retrieving';
  170.     commentedButton.src = retrievingButtonImg;
  171.  
  172.      var photoUrl = document.evaluate('.//a', thumbnail, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).
  173.             singleNodeValue.href;
  174.     getPhotoComments(photo_id, photoUrl);
  175.  
  176.     return libut;
  177. }
  178.  
  179. function addButtonToPoolItem(thumbnail) {
  180.     var photo_id = thumbnail.getAttribute('data-photo-id');
  181.     var hover = document.evaluate('.//div[contains(@class,"hover-target")]', thumbnail, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  182.     var meta = document.evaluate('.//div[contains(@class,"meta")]', thumbnail, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  183.     meta.setAttribute('style', 'display: inline-block; vertical-align: top;');
  184.     addButtonToThumbnail(hover, photo_id, meta);
  185. }
  186.  
  187. GM_addStyle(".FCO-gradient { " +
  188.     "background: -webkit-gradient(radial, center center, 0, center center, 24, from(#bbbbbb), to(#ffffff)); " +
  189.     "background: -webkit-radial-gradient(#bbbbbb, #ffffff); " +
  190.     "background: -moz-radial-gradient(circle, #bbbbbb, #ffffff); " +
  191.     "}; ");
  192.  
  193. function addButtonToJustifiedPoolItem(thumbnail, photo_id) { // photo_id passed for stream items
  194.     if (!photo_id) {
  195.         photo_id = thumbnail.getAttribute('data-photo-id');
  196.     }
  197.     if ( document.getElementById('FCO-image-' + photo_id) ) { // there already is one (set page, apps page, ..)
  198.         return;
  199.     }
  200.     var libut = thumbnail.appendChild(document.createElement('div'));
  201.         libut.setAttribute('style','display: inline-block; height: 24px; position: absolute; left: 10px; top: 10px;');
  202.     libut.setAttribute('id', 'FCO-photo-' + photo_id);
  203.     var divbut = libut.appendChild(document.createElement('a'));
  204.         divbut.setAttribute('style', 'height:24px;');
  205.         divbut.href = "#";
  206.     var commentedButton = divbut.appendChild(document.createElement('img'));
  207.         commentedButton.setAttribute('style', 'height:24px;');
  208.     commentedButton.setAttribute('class', 'FCO-gradient');
  209.         commentedButton.id = 'FCO-image-' + photo_id;
  210.         commentedButton.title = 'retrieving';
  211.         commentedButton.src = retrievingButtonTransparentImg;
  212.  
  213.         var photoUrl = document.evaluate('.//span[contains(@class,"photo_container")]/a', thumbnail, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.href;
  214.     getPhotoComments(photo_id, photoUrl);
  215.  
  216.     return libut;
  217. }
  218.  
  219. function setCommented(commented, photo_id, href, comment_count)
  220. {
  221.     var commentedButton = document.getElementById('FCO-image-' + photo_id);
  222.     if (!commentedButton) {
  223.     return;
  224.     }
  225.     switch (commented) {
  226.         case 'yes':
  227.             commentedButton.src = commentedButton.className.match('FCO-gradient') ? commentedButtonTransparentImg : commentedButtonImg;
  228.             commentedButton.alt = "Yay! You've commented on this photo!";// semicolon
  229.         if (SHOW_COMMENT_COUNT) {
  230.             var countId = 'FCO-image-count-' + photo_id;
  231.             if (!document.getElementById(countId)) {
  232.                         var count = document.createElement('span');
  233.                 count.id = countId;
  234.                         count.setAttribute('style', "display:inline;z-index: 2; position: relative; left: -15px; top: -12px; font-size: 10px; color: white;padding: 0px;border-right:0;");
  235.                         count.innerHTML = comment_count;
  236.                         count.title = commentedButton.alt;
  237.                 commentedButton.parentNode.appendChild(count);
  238.             }
  239.                 }
  240.             break;
  241.         case 'no':
  242.             commentedButton.src = commentedButton.className.match('FCO-gradient') ? notCommentedButtonTransparentImg : notCommentedButtonImg;
  243.             commentedButton.alt = "Go ahead! Make my day! (by commenting)";
  244.         break;
  245.         case 'error':
  246.                 commentedButton.src = commentedButton.className.match('FCO-gradient') ? errorCommentedButtonTransparentImg : errorCommentedButtonImg;
  247.                 commentedButton.alt = "Error: " + comment_count;
  248.             break;
  249.         default:
  250.             commentedButton.src = commentedButton.className.match('FCO-gradient') ? errorCommentedButtonTransparentImg : errorCommentedButtonImg;
  251.             commentedButton.alt = "Error: " + commented;
  252.             break;
  253.     }
  254.     commentedButton.title = commentedButton.alt;
  255.     if (href == "#reply-box") { // when clicked, go to the reply-box, and set focus
  256.         commentedButton.style.cursor = 'pointer';
  257.         commentedButton.addEventListener('click', function (e) {
  258.             var textarea = document.getElementById('message');
  259.             textarea.focus();
  260.             textarea.setSelectionRange(0,0);
  261.         }, false);
  262.     } else {
  263.         commentedButton.parentNode.href = href;
  264.     }
  265. }
  266.  
  267. // DECEMBRE CORRECTION 2014 : https://www.flickr.com/groups/flickrhacks/discuss/72157645811287588/#comment72157648370481010
  268. function getUsername() {
  269. //  var buddyIcon = document.evaluate('.//a[contains(@class,"account")]/img[contains(@class,"gn-buddyicon")]', document, null,
  270. //          XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  271.  
  272.             var buddyIcon = document.evaluate('.//span[contains(@class,"account")]/img[contains(@class,"gn-buddyicon")]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  273.  
  274.     if (!buddyIcon) return null;
  275.     return buddyIcon.src.match(/flickr.com\/\d+\/buddyicons\/(\d+@\w\d{2})/)[1];
  276. }
  277.  
  278. // thanks to Vispillo (http://www.flickr.com/photos/31747528@N05/):
  279. var getJSVariable = function(regex) {
  280.                 // Thanks to Vispillo for this compact code
  281.                 var scripts = document.getElementsByTagName('script');
  282.         for (var i = 0; i < scripts.length; ++i) {
  283.                         var html = scripts[i].innerHTML;
  284.             try {
  285.                 return html.match(regex)[1];
  286.             } catch(e) {
  287.             }
  288.                 }
  289.                 return undefined;
  290. };// semicolon
  291. var api_key = getJSVariable(/[\"\']api_key[\"\'][ :]+[\"\']([^\"\']+)[\"\']/);
  292. var auth_hash = getJSVariable(/[\"\']auth_hash[\"\'][ :]+[\"\']([^\"\']+)[\"\']/);
  293.  
  294. function getPhotoComments(photo_id, commentHref)
  295. {
  296.  
  297. // HTTPS
  298.     GM_xmlhttpRequest({
  299.             method:"GET",
  300.             // use www.flickr.com to call the api (same servers :) ), to make it work in Chrome
  301.             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,
  302.             onload:function(details) {
  303.                 try{
  304.                     try {
  305.                         var data = JSON.parse(details.responseText);
  306.                     } catch (e) { // older versions of FF don't have JSON
  307.             try {
  308.                             data = eval( '(' + details.responseText + ')');
  309.             } catch (f) {
  310.                 GM_log("error parsing JSON data: " + e);
  311.                 GM_log("received from server for photo_id(" + photo_id + "): '" + details.responseText + "'");
  312.                 setCommented('error', photo_id, commentHref, e);
  313.                 return;
  314.             }
  315.                     }
  316.                     if (data.stat == 'ok') {
  317.                         var comments = data.comments.comment;
  318.                         var commented = false;
  319.             var comment_count = 0;
  320.             var permalink = undefined;
  321.                         if (comments) {
  322.                             comments.forEach(function(comment, idx) {
  323.                                 if (commented && !SHOW_COMMENT_COUNT) return;
  324.                                 if (comment.authorname == user_name || comment.author == user_name) {
  325.                                     commented = true;
  326.                     ++comment_count;
  327.                                     if (permalink == undefined) permalink = comment.permalink;
  328.                                 }
  329.                             });
  330.                         if (commented) {
  331.                         setCommented('yes', photo_id, permalink.replace('#comment', 'comment'), comment_count);
  332.                 } else {
  333.                         setCommented('no', photo_id, commentHref, comment_count);
  334.                     }
  335.                         } else {
  336.                             setCommented('no', photo_id, commentHref, comment_count);
  337.                         }
  338.                     } else {
  339.                         setCommented(data.code + " - " + data.message, photo_id, commentHref, comment_count);
  340.                     }
  341.                 } catch(e) {
  342.                     GM_log("error parsing API result: " + e);
  343.             GM_log("response received: " + details.responseText);
  344.             setCommented('error', photo_id, commentHref, e + ' - ' + details.responseText);
  345.                 }
  346.             },
  347.             onerror: function(details) {
  348.                 GM_log("error: " + details.statusText);
  349.         setCommented('error', photo_id, commentHref, details.statusText);
  350.             }
  351.     });
  352.  
  353. }
  354.  
  355. var user_name = getUsername();
  356. if(!user_name) {
  357.     GM_log("no user name found");
  358.     return;
  359. } else {
  360.     GM_log("running for user " + user_name);
  361. }
  362.  
  363.  
  364. // TEST not Working : TWEAK DECEMBRE : .new-comment-text
  365. // TEST 2018 -
  366. try {
  367. if (document.location.href.match(/.*flickr.com\/photos\/[^\/]+\/\d+/)) { // on photo page
  368.     // add a 'reply' name anchor to jump to on button click
  369.     var anchorInCommentForm = document.evaluate('//div[contains(@class,"add-comment-form")]//a', document, null,
  370. //      var anchorInCommentForm = document.evaluate('//div[contains(@class,"new-comment-text")]//a', document, null,
  371.         XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  372.     if (anchorInCommentForm) { // no comment form: no permission to comment
  373.         anchorInCommentForm.setAttribute('name', 'reply-box');
  374.     }
  375.     var photo_id = document.location.href.match(/.*flickr.com\/photos\/[^\/]+\/(\d+)/)[1];
  376.  
  377.     addButtonToMenu(photo_id);
  378.     getPhotoComments(photo_id, "#reply-box");
  379.  
  380. // 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")
  381. // 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")
  382.  
  383.     // [2025.01] DECEMBRE FIX POOL SM - NEW URL - https://www.flickr.com/groups_pool.gne?path=portrait_face&nsid=&page=&jump_to=&thumb=1
  384. } else if (document.location.href.match(/.*flickr.com\/groups\/[^\/]+\/?$/) ||// group start pages
  385.        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
  386.        document.location.href.match(/.*flickr.com\/groups\/[^\/]+\/pool/) ||// group pools
  387.        document.location.href.match(/.*flickr.com\/photos\/[^\/]+\/favorites/) ||// favorites pages
  388.        document.location.href.match(/.*flickr.com\/photos\/[^\/]+\/archives/) ||// archive pages
  389.        document.location.href.match(/.*flickr.com\/photos\/friends/)) {// friends
  390.  
  391.     var poolPhotos = document.evaluate('//div[contains(@class,"pool-photo") or contains(@class,"fave") or contains(@class,"photo-display-item")]',
  392.         document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  393.     if (poolPhotos.snapshotLength <= 0) {
  394.         GM_log("no photos found, aborting");
  395.     return;
  396.     }
  397.     var poolItemDecorator = addButtonToJustifiedPoolItem; // assume justified view
  398.     var squarePhotos = document.evaluate('count(//span[contains(@class,"pc_s")])', document, null,
  399.             XPathResult.ANY_TYPE, null);
  400.     if (squarePhotos.numberValue == poolPhotos.snapshotLength) {
  401.         // square thumbnails view
  402.     poolItemDecorator = null; // not on squares!
  403.     // except on set pages:
  404.     //if (document.location.href.match(/.*flickr.com\/photos\/[^\/]+\/sets/)) {
  405.         poolPhotos = document.evaluate('//span[contains(@class,"photo_container")]', document, null,
  406.                 XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  407.         poolItemDecorator = addButtonToThumbnail;
  408.     //}
  409.     } else {
  410.         var smallPhotos = document.evaluate('count(//span[contains(@class,"pc_t")])', document, null,
  411.         XPathResult.ANY_TYPE, null);
  412.     if (smallPhotos.numberValue == poolPhotos.snapshotLength) {
  413.         // small thumbnails view
  414.         poolItemDecorator = addButtonToPoolItem;
  415.     } else {
  416.         var mediumPhotos = document.evaluate('count(//span[contains(@class,"pc_m")])', document, null,
  417.             XPathResult.ANY_TYPE, null);
  418.         if (mediumPhotos.numberValue == poolPhotos.snapshotLength) {
  419.             // medium view
  420.             poolItemDecorator = addButtonToPoolItem;
  421.         } else {
  422.             var largePhotos = document.evaluate('count(//span[contains(@class,"pc_z")])', document, null,
  423.                 XPathResult.ANY_TYPE, null);
  424.             if (largePhotos.numberValue == poolPhotos.snapshotLength) {
  425.                 // large view
  426.                 poolItemDecorator = addButtonToPoolItem;
  427.             } else {
  428.                 //alert("justified view (" + poolPhotos.snapshotLength + ")");
  429.             }
  430.         }
  431.     }
  432.     }
  433.  
  434.     if (!poolItemDecorator) {
  435.     return;
  436.     }
  437.  
  438.     for (var i = 0, len = poolPhotos.snapshotLength; i < len; ++i) {
  439.         var thumbnail = poolPhotos.snapshotItem(i);
  440.     poolItemDecorator(thumbnail);
  441.     }
  442.     document.getElementById('main').addEventListener('DOMNodeInserted', function(event) {
  443.         setTimeout(function() { // workaround: addEventListener callback gets called in unsafeWindow!
  444.             try {
  445.                     var target = event.target;
  446.                     if (target.nodeName == 'DIV' && (target.className.match('pool-photo') || target.className.match('fave') || target.className.match('photo-display-item'))) {
  447.                 poolItemDecorator(target);
  448.                     }
  449.             } catch (e) {
  450.                     GM_log("error on insert: " + e);
  451.             }
  452.     }, 0);
  453.     }, true);
  454. } else if (document.location.href.match(/.*flickr.com\/photosof\/contacts/) ||// contacts
  455.            document.location.href.match(/.*flickr.com\/activity/)) {// recent activity
  456.     var poolThumbnails = document.evaluate('//span[contains(@class,"photo_container")]', document, null,
  457.         XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  458.     for (var i = 0, len = poolThumbnails.snapshotLength; i < len; ++i) {
  459.         var thumbnail = poolThumbnails.snapshotItem(i);
  460.         try {
  461.             var photo_id = document.evaluate('./a/img', thumbnail, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).
  462.                 singleNodeValue.src.match(/.*flickr.com\/\d+\/(\d+)_.*/)[1];
  463.         } catch (e) {
  464.             continue;
  465.         }
  466.         var commentedOnButton = addButtonToThumbnail(thumbnail, photo_id);
  467.         try {
  468.             // move the balloon
  469.             thumbnail.parentNode.insertBefore(commentedOnButton, thumbnail.nextSibling.nextSibling.nextSibling); // span - br
  470.         } catch (e) {
  471.             try {
  472.                 thumbnail.parentNode.insertBefore(commentedOnButton, thumbnail.nextSibling);
  473.             } catch (e) {
  474.                 GM_log("error inserting: " + e);
  475.             }
  476.             GM_log("error moving: " + e);
  477.             // ignore: let it be
  478.         }
  479.     }
  480. } else if (document.location.href.match(/.*flickr.com\/photos\/[^\/]+(\/page\d+|\/with\/\d+.*)?\/?$/) || // stream pages
  481.        document.location.href.match(/.*flickr.com\/photos\/[^\/]+\/sets/)) {// set pages
  482.     document.getElementById('main').addEventListener('DOMNodeInsertedIntoDocument', function(evt) {
  483.         setTimeout(function() { // workaround: addEventListener callback gets called in unsafeWindow!
  484.             try {
  485.                     var target = evt.target;
  486.                     if (target.nodeName == 'SPAN' && target.className.match("attribution")) {
  487.                 //unsafeWindow.console.log("add attribution");
  488.                 var thumbnailDiv = document.evaluate('.//ancestor::div[contains(@class,"photo-display-item")]', target, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  489.                 var photo_id = thumbnailDiv.getAttribute('data-photo-id');
  490.                 var thumbnail = document.evaluate('.//div[contains(@class,"thumb")]', thumbnailDiv, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  491.                 addButtonToJustifiedPoolItem(thumbnail, photo_id);
  492.                     } else if (target.nodeName == 'DIV' && target.className.match("cover-photo-position")) { // page has been reloaded: re-run
  493.                 //unsafeWindow.console.log("add buttons");
  494.                     var streamItems = document.evaluate('//div[contains(@class,"photo-display-item")]', document, null,
  495.                     XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  496.                     for (var i = 0, len = streamItems.snapshotLength; i < len; ++i) {
  497.                     var streamItem = streamItems.snapshotItem(i);
  498.                     var photo_id = streamItem.getAttribute('data-photo-id');
  499.                     var thumbnail = document.evaluate('.//div[contains(@class,"thumb")]', streamItem, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  500.                     addButtonToJustifiedPoolItem(thumbnail, photo_id);
  501.                     }
  502.             } else {
  503.                 //unsafeWindow.console.log("adding " + target.nodeName + "(class:" + target.className + ")");
  504.             }
  505.             } catch (e) {
  506.                     GM_log("error on insert: " + e);
  507.             }
  508.     }, 0);
  509.     }, true);
  510.         var streamItems = document.evaluate('//div[contains(@class,"photo-display-item")]', document, null,
  511.         XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  512.         for (var i = 0, len = streamItems.snapshotLength; i < len; ++i) {
  513.         var streamItem = streamItems.snapshotItem(i);
  514.         var photo_id = streamItem.getAttribute('data-photo-id');
  515.         var thumbnail = document.evaluate('.//div[contains(@class,"thumb")]', streamItem, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  516.         addButtonToJustifiedPoolItem(thumbnail, photo_id);
  517.         }
  518. } else if (document.location.href.match(/.*flickr.com\/?$/)) {// flickr home page
  519.     var imageItems = document.evaluate('//div[contains(@class,"imgWrapper")]', document, null,
  520.         XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  521.     for (var i = 0, len = imageItems.snapshotLength; i < len; ++i) {
  522.     var imageItem = imageItems.snapshotItem(i);
  523.     var photo_id = imageItem.getAttribute('data-photo-id');
  524.     var imgLinks = document.evaluate('.//ul[contains(@class,"imgLinks")]', imageItem, null,
  525.         XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  526.     addButtonToImageCard(imgLinks, photo_id);
  527.     var photoUrl = document.evaluate('.//a', imageItem, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).
  528.             singleNodeValue.href;
  529.     getPhotoComments(photo_id, photoUrl);
  530.     }
  531. }
  532.  
  533. } catch (e) { console.error('exception:', e); }
  534.  
  535. })();
  536.  
  537.  
Comments
  • decembre
    1 year (edited)
    Comment was deleted
  • decembre
    130 days (edited)
    Comment was deleted
Add Comment
Please, Sign In to add comment