Flickr - AUTO More Comments v.7

PHOTO / ALBUM Auto Load ALL comments

  1. // ==UserScript==
  2. // @name Flickr - AUTO More Comments v.7
  3. // @description PHOTO / ALBUM Auto Load ALL comments
  4.  
  5. // @version v.7.2
  6. // @include http*://www.flickr.com/photos/*
  7. // @include https://www.flickr.com/photos/*/sets/*
  8. // @include https://www.flickr.com/photos/*/albums/*
  9.  
  10. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
  11.  
  12. // @autor decembre / Brock Adams
  13.  
  14. // @grant GM_addStyle
  15.  
  16. // @run-at document-start
  17.  
  18. // @namespace https://greasyfork.org/users/8
  19. // ==/UserScript==
  20.  
  21. // FROM a script of Brock Adams (Thanks to him!)
  22. // in stackoverflow :
  23. // http://stackoverflow.com/questions/12252701/how-do-i-click-on-this-button-with-greasemonkey?lq=1
  24. // with :
  25. // https://gist.github.com/raw/2625891/waitForKeyElements.js
  26.  
  27. /*- The @grant directive is needed to work around a major design change
  28. introduced in GM 1.0.
  29. It restores the sandbox.
  30. */
  31.  
  32.  
  33. /*--- waitForKeyElements():
  34.  
  35. FIND IT HERE :
  36. https://gist.github.com/raw/2625891/waitForKeyElements.js
  37.  
  38. A utility function, for Greasemonkey scripts,
  39. that detects and handles AJAXed content.
  40.  
  41. Usage example:
  42.  
  43. waitForKeyElements (
  44. "div.comments"
  45. , commentCallbackFunction
  46. );
  47.  
  48. //--- Page-specific function to do what we want when the node is found.
  49. function commentCallbackFunction (jNode) {
  50. jNode.text ("This comment changed by waitForKeyElements().");
  51. }
  52.  
  53. IMPORTANT: This function requires your script to have loaded jQuery.
  54. */
  55. function waitForKeyElements (
  56. selectorTxt, /* Required: The jQuery selector string that
  57. specifies the desired element(s).
  58. */
  59. actionFunction, /* Required: The code to run when elements are
  60. found. It is passed a jNode to the matched
  61. element.
  62. */
  63. bWaitOnce, /* Optional: If false, will continue to scan for
  64. new elements even after the first match is
  65. found.
  66. */
  67. iframeSelector /* Optional: If set, identifies the iframe to
  68. search.
  69. */
  70. ) {
  71. var targetNodes, btargetsFound;
  72.  
  73. if (typeof iframeSelector == "undefined")
  74. targetNodes = $(selectorTxt);
  75. else
  76. targetNodes = $(iframeSelector).contents ()
  77. .find (selectorTxt);
  78.  
  79. if (targetNodes && targetNodes.length > 0) {
  80. btargetsFound = true;
  81. /*--- Found target node(s). Go through each and act if they
  82. are new.
  83. */
  84. targetNodes.each ( function () {
  85. var jThis = $(this);
  86. var alreadyFound = jThis.data ('alreadyFound') || false;
  87.  
  88. if (!alreadyFound) {
  89. //--- Call the payload function.
  90. var cancelFound = actionFunction (jThis);
  91. if (cancelFound)
  92. btargetsFound = false;
  93. else
  94. jThis.data ('alreadyFound', true);
  95. }
  96. } );
  97. }
  98. else {
  99. btargetsFound = true;
  100. }
  101.  
  102. //--- Get the timer-control variable for this selector.
  103. var controlObj = waitForKeyElements.controlObj || {};
  104. var controlKey = selectorTxt.replace (/[^\w]/g, "_");
  105. var timeControl = controlObj [controlKey];
  106.  
  107. //--- Now set or clear the timer as appropriate.
  108. if (btargetsFound && bWaitOnce && timeControl) {
  109. //--- The only condition where we need to clear the timer.
  110. clearInterval (timeControl);
  111. delete controlObj [controlKey]
  112. }
  113. else {
  114. //--- Set a timer, if needed.
  115. if ( ! timeControl) {
  116. timeControl = setInterval ( function () {
  117. waitForKeyElements ( selectorTxt,
  118. actionFunction,
  119. bWaitOnce,
  120. iframeSelector
  121. );
  122. },
  123. 300
  124. );
  125. controlObj [controlKey] = timeControl;
  126. }
  127. }
  128. waitForKeyElements.controlObj = controlObj;
  129. }
  130.  
  131.  
  132.  
  133. //--- Note that contains() is CASE-SENSITIVE.
  134. //waitForKeyElements ("a.simplebutton:contains('follow')", clickOnFollowButton);
  135.  
  136. // PB - - PHOTO pages - VIEW USER INFOS - CLIK OVERLAY
  137. /*
  138. waitForKeyElements (".fluid-droparound-overlay.transparent ", clickOnOverlay);
  139.  
  140. function clickOnOverlay (jNode) {
  141. var clickEvent = document.createEvent ('MouseEvents');
  142. clickEvent.initEvent ('click', true, true);
  143. jNode[0].dispatchEvent (clickEvent);
  144. }
  145. */
  146.  
  147. // NOT NEED it NOW
  148. // read: https://www.flickr.com/help/forum/en-us/72157720163194555/#reply72157720164428390
  149. // PHOTO pages - VIEW USER INFOS (new2)
  150. // PB solved by CSS : PHOTO STREAM - https://www.flickr.com/photos/16062610@N00/
  151. // .fluid.html-photo-page-scrappy-view .avatar.person.medium
  152. // .view-all-contexts-of-type>a
  153. /*
  154. waitForKeyElements (".height-controller.enable-zoom .avatar.person.medium", clickOnUserButton);
  155. function clickOnUserButton (jNode) {
  156. var clickEvent = document.createEvent ('MouseEvents');
  157. clickEvent.initEvent ('click', true, true);
  158. jNode[0].dispatchEvent (clickEvent);
  159. }
  160. */
  161.  
  162. // TEST - OK ALBUM pages - PB NO SETS pages (identicals) - VIEW USER INFOS
  163. // Example FOR: https://www.flickr.com/photos/137620031@N05/33277376702/in/album-72157676721768741/
  164. // WHEN YOU click ON ALBUM "Models" you go to SET pages
  165. // if you reload it you go to album pages (identicals pages but "album" in url ????
  166.  
  167. // .fluid.html-album-page-view .avatar.person.medium
  168. // NOT WORK on SET :
  169. // https://www.flickr.com/photos/137620031@N05/sets/72157677962971581
  170.  
  171. // .fluid.html-album-page-view .avatar.person.medium
  172. // WORK on ALBUM (identical but album in url ) :
  173. // https://www.flickr.com/photos/137620031@N05/albums/72157677962971581
  174.  
  175. // ALBUM
  176. /*
  177. waitForKeyElements (".fluid.html-album-page-view .avatar.person.medium", clickOnAlbumUserButton);
  178. function clickOnAlbumUserButton (jNode) {
  179. var clickEvent = document.createEvent ('MouseEvents');
  180. clickEvent.initEvent ('click', true, true);
  181. jNode[0].dispatchEvent (clickEvent);
  182. }
  183. // SET
  184. waitForKeyElements (".fluid.html-set-page-view .avatar.person.medium", clickOnSetUserButton);
  185. function clickOnSetUserButton (jNode) {
  186. var clickEvent = document.createEvent ('MouseEvents');
  187. clickEvent.initEvent ('click', true, true);
  188. jNode[0].dispatchEvent (clickEvent);
  189. }
  190. */
  191.  
  192. // VIEW ALL POOLS
  193. /*
  194. waitForKeyElements (".view-all-contexts-of-type>a", clickOnPollButton);
  195. function clickOnPollButton (jNode) {
  196. var clickEvent = document.createEvent ('MouseEvents');
  197. clickEvent.initEvent ('click', true, true);
  198. jNode[0].dispatchEvent (clickEvent);
  199. }
  200. */
  201.  
  202. // TEST MAIL ALERT - A VOIR
  203. /*
  204. waitForKeyElements (".c-notifications-menu span", clickMAILalert);
  205. function clickMAILalert (jNode) {
  206. var clickEvent = document.createEvent ('MouseEvents');
  207. clickEvent.initEvent ('click', true, true);
  208. jNode[0].dispatchEvent (clickEvent);
  209. }
  210. */
  211. // MORE COMMENTS
  212. /*waitForKeyElements('.sub-photo-content-container .photo-comments.with-emoji-picker a.load-more-button', actionFunction, false);*/
  213. (function(){
  214. function actionMoreCommnents(node){
  215. console.log ("Found More Comments ButtoN. Clicking it!");
  216. //node.click();
  217. var clickEvent = document.createEvent ('MouseEvents');
  218. clickEvent.initEvent ('click', true, true);
  219. node[0].dispatchEvent (clickEvent);
  220. return true;
  221. }
  222. console.log ("Waiting for More Comments ButtoN");
  223. waitForKeyElements(".sub-photo-content-container .photo-comments.with-emoji-picker a.load-more-button:not(.hidden)", actionMoreCommnents);
  224. })();