decembre

GM - Flickr Commented On (HTTPS) - TWEAK 2025 (new url POOL SM)

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