Flickr - AUTO More Comments v.7

2017 - ok PHOTO / ALBUM - PB SET - View Info on Hover User's Buddy and Auto Load ALL comments - (author Brock Adams , fork decembre)

Fra og med 11.08.2023. Se den nyeste version.

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