Advertisement
decembre

GM - Flickr - AUTO View User Infos v.2

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