Add thumbs to StatCounter with GreaseMonkey

13»

Comments

  • rsirotarsirota Registered Users Posts: 111 Major grins
    edited August 26, 2008
    Am I missing something?

    I added Greasemonkey to FF.
    I added the script in the main message to my scripts

    I see nothing...

    Thanks...
    Rob Sirota
    Web: www.robsirotaphotography.comwww.k9-pix.comwww.rsirota.com
    Nikon... All Nikon (D4/D810/Dƒ)
    ... OK I do have a PhaseOne 645DF+ w/IQ250
  • jfriendjfriend Registered Users Posts: 8,097 Major grins
    edited August 26, 2008
    rsirota wrote:
    Am I missing something?

    I added Greasemonkey to FF.
    I added the script in the main message to my scripts

    I see nothing...

    Thanks...

    That's what I see. Does it work?

    When you do a "Visitor Paths" view in StatCounter, do you get any thumbnails to show you which image people are hitting?

    If it's working, you should see something like this:
    path__ivar_s_photos_-20071010-180910.jpg
    --John
    HomepagePopular
    JFriend's javascript customizationsSecrets for getting fast answers on Dgrin
    Always include a link to your site when posting a question
  • rsirotarsirota Registered Users Posts: 111 Major grins
    edited August 26, 2008
    jfriend wrote:
    That's what I see. Does it work?

    When you do a "Visitor Paths" view in StatCounter, do you get any thumbnails to show you which image people are hitting?

    If it's working, you should see something like this:
    path__ivar_s_photos_-20071010-180910.jpg

    Nothing just get text.. It is a custom domain does that matter?
    Rob Sirota
    Web: www.robsirotaphotography.comwww.k9-pix.comwww.rsirota.com
    Nikon... All Nikon (D4/D810/Dƒ)
    ... OK I do have a PhaseOne 645DF+ w/IQ250
  • jfriendjfriend Registered Users Posts: 8,097 Major grins
    edited August 26, 2008
    rsirota wrote:
    Nothing just get text.. It is a custom domain does that matter?
    The latest version should work with a custom domain (earlier versions did not). You might try creating some hits when visiting nickname.smugmug.com just to see if that works and it is an issue with the custom domain.

    Are you sure you have the latest version of the code? You can get the latest version here.
    --John
    HomepagePopular
    JFriend's javascript customizationsSecrets for getting fast answers on Dgrin
    Always include a link to your site when posting a question
  • rsirotarsirota Registered Users Posts: 111 Major grins
    edited August 26, 2008
    jfriend wrote:
    The latest version should work with a custom domain (earlier versions did not). You might try creating some hits when visiting nickname.smugmug.com just to see if that works and it is an issue with the custom domain.

    Are you sure you have the latest version of the code? You can get the latest version here.

    Got it working.. .One question though, can it be made to work with the "Recent Visitor Activity" page too?
    Rob Sirota
    Web: www.robsirotaphotography.comwww.k9-pix.comwww.rsirota.com
    Nikon... All Nikon (D4/D810/Dƒ)
    ... OK I do have a PhaseOne 645DF+ w/IQ250
  • jfriendjfriend Registered Users Posts: 8,097 Major grins
    edited August 26, 2008
    rsirota wrote:
    Got it working.. .One question though, can it be made to work with the "Recent Visitor Activity" page too?

    It could be made to work with that page. I don't know if I have time, but what would you want it to show thumbs for?
    --John
    HomepagePopular
    JFriend's javascript customizationsSecrets for getting fast answers on Dgrin
    Always include a link to your site when posting a question
  • rsirotarsirota Registered Users Posts: 111 Major grins
    edited August 26, 2008
    jfriend wrote:
    It could be made to work with that page. I don't know if I have time, but what would you want it to show thumbs for?

    It is the same format (at least it looks like it...) Just showing the entry and exit page...
    Rob Sirota
    Web: www.robsirotaphotography.comwww.k9-pix.comwww.rsirota.com
    Nikon... All Nikon (D4/D810/Dƒ)
    ... OK I do have a PhaseOne 645DF+ w/IQ250
  • jfriendjfriend Registered Users Posts: 8,097 Major grins
    edited August 26, 2008
    rsirota wrote:
    It is the same format (at least it looks like it...) Just showing the entry and exit page...

    The reason I asked is that most of mine show an entry page of my home page or a category so there's no thumb to show anyway (it has to be a gallery link or specific image link to get a thumb).

    And for the exit page, it didn't seem all that informative to see a thumb for the image they looked at last.
    --John
    HomepagePopular
    JFriend's javascript customizationsSecrets for getting fast answers on Dgrin
    Always include a link to your site when posting a question
  • rsirotarsirota Registered Users Posts: 111 Major grins
    edited August 26, 2008
    jfriend wrote:
    The reason I asked is that most of mine show an entry page of my home page or a category so there's no thumb to show anyway (it has to be a gallery link or specific image link to get a thumb).

    And for the exit page, it didn't seem all that informative to see a thumb for the image they looked at last.

    Mine can show the main page but the exit page is usually the picture. Also the entry is a gallery sometime too...
    Rob Sirota
    Web: www.robsirotaphotography.comwww.k9-pix.comwww.rsirota.com
    Nikon... All Nikon (D4/D810/Dƒ)
    ... OK I do have a PhaseOne 645DF+ w/IQ250
  • AllenAllen Registered Users Posts: 10,013 Major grins
    edited August 27, 2008
    rsirota wrote:
    Got it working.. .One question though, can it be made to work with the "Recent Visitor Activity" page too?
    Works fine here on the Recent Visitor Activity page.

    Wish Smug would kick out something that SC would sence for the map_this or Full screen show.
    Al - Just a volunteer here having fun
    My Website index | My Blog
  • coldclimbcoldclimb Registered Users Posts: 1,169 Major grins
    edited January 3, 2010
    Allen wrote:
    Works fine here on the Recent Visitor Activity page.

    Wish Smug would kick out something that SC would sence for the map_this or Full screen show.

    This isn't working for me... is this script still up to date? Looks kinda handy and I'd like to try it out...


    Edit: Now it's working! Thanks anyway! :D
    John Borland
    www.morffed.com
  • AllenAllen Registered Users Posts: 10,013 Major grins
    edited January 17, 2010
    John, any chance of updating for niceNames?
    Al - Just a volunteer here having fun
    My Website index | My Blog
  • jfriendjfriend Registered Users Posts: 8,097 Major grins
    edited January 17, 2010
    Allen wrote:
    John, any chance of updating for niceNames?
    This is what I'm running with. It's been slightly fixed for nicenames, though there is still more that could be done. I am not supporting this script, just offering what I have "as is".
    // ==UserScript==
    // @namespace     http://nimai.smugmug.com/statcounterthumbs
    // @name          StatCounter SmugMug Thumbs
    // @description   Adds thumbnails to the detailed view of StatCounter
    // @include       http://*.statcounter.com/project/standard/*
    // ==/UserScript==
    
    
    // Updated on 9-10-29009  by John Friend
    // Modified script to work with some of the new nicename URLs
    // Modified script so it works with any domain, including custom domains
    // Added support for image Keys so it works with new galleries that required image Keys
    // Added support for a number of addition URL formats that didn't previously work
    // Added a thumbnail display for URLs that only have a gallery ID and key in them (and made them left aligned to distinguish them)
    // Removed support for URLs that do not have an imageKey in them (they would only work on old galleries anyway)
    // Added support for date query URLs that have an imageID and imageKey
    // Combined popular, date and keyword regEx into one common expression
    
    
    
    //--------------------------------------------------------------------------------
    function getElementsByClass(searchClass,node,tag) {
      var classElements = new Array();
      if (node == null)
        node = document;
      if (tag == null)
        tag = '*';
      var els = node.getElementsByTagName(tag);
      var elsLen = els.length;
      var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
      for (i = 0, j = 0; i < elsLen; i++) {
        if (pattern.test(els[i].className) ) {
          classElements[j] = els[i];
          j++;
        }
      }
      return classElements;
    }
    
    
    //--------------------------------------------------------------------------------
    //var imgRegExp = new RegExp('([^\.]+\.smugmug\.com/)(?:gallery/[0-9/]+#([0-9]+)|keyword/[^/]+(?:/[0-9]+/|#)([0-9]+)|popular/(?:[0-9]+/|#)([0-9]+))');
    //var imgRegExp = new RegExp('(^[^/]+/)(?:gallery/[0-9_a-zA-Z/]+#([0-9]+_[0-9a-zA-Z]+)|gallery/[0-9]+_[0-9a-zA-Z]+/[0-9]+/([0-9]+_[0-9a-zA-Z]+)|keyword/[^/]+(?:/[0-9]+/|#)([0-9]+)|popular/(?:[0-9]+/[0-9_a-zA-Z]+#|#)([0-9]+_[0-9a-zA-Z]+|[0-9]+))');
    //var imgRegExp = new RegExp('(^[^/]+/)(?:gallery/[0-9_a-zA-Z/]+#([0-9]+_[0-9a-zA-Z]+)|gallery/[0-9]+_[0-9a-zA-Z]+/[0-9]+/([0-9]+_[0-9a-zA-Z]+)|keyword/[^/]+(?:/[0-9]+/|#)([0-9]+)|popular/.*(?:#|/)([0-9]+_[0-9a-zA-Z]+)$)');
    //var imgRegExp = new RegExp('(^[^/]+/)(?:gallery/[0-9]+_[0-9a-zA-Z]+(?:#|/[0-9]+/)([0-9]+_[0-9a-zA-Z]+)|keyword/[^/]+(?:/[0-9]+/|#)([0-9]+)|popular/.*(?:#|/)([0-9]+_[0-9a-zA-Z]+)$)');
    //var imgRegExp = new RegExp('(^[^/]+/)(?:gallery/[0-9]+_[0-9a-zA-Z]+(?:#|/[0-9]+/)([0-9]+_[0-9a-zA-Z]+)|keyword/[^/]+(?:/[0-9]+/|#)([0-9]+)|popular/.*(?:#|/)([0-9]+_[0-9a-zA-Z]+)(?:(?:/|\-)[A-Za-z\-]+)*$)');
    //var imgRegExp = new RegExp('(^[^/]+/)(?:gallery/[0-9]+_[0-9a-zA-Z]+(?:#|/[0-9]+/)([0-9]+_[0-9a-zA-Z]+)|(?:popular|date|keyword)/.*(?:#|/)([0-9]+_[0-9a-zA-Z]+)(?:(?:/|\-)[A-Za-z\-]+)*$)');
    
    var imgRegExp = new RegExp('(^[^/]+/)(?:gallery/[0-9]+_[0-9a-zA-Z]+(?:[^#]*#|/[0-9]+/)([0-9]+_[0-9a-zA-Z]+)|(?:popular|date|keyword)/.*(?:#|/)([0-9]+_[0-9a-zA-Z]+)(?:(?:/|\-)[A-Za-z\-]+)*$)');
    var galleryRegExp = new RegExp('(^[^/]+/)(?:gallery(/[0-9]+_[0-9a-zA-Z]+)(?:$|#P[\-0-9]+$))');
    
    // http://jfriend.smugmug.com/Portfolio/Wildlife/879694_PGHnN#39934670_buaG8
    var nicenameImageRegExp = new RegExp('(^[^/]+/).*#([0-9]+_[0-9a-zA-Z]+)');
    
    // http://jfriend.smugmug.com/Portfolio/Wildlife/879694_PGHnN
    var nicenameGalleryRegExp = new RegExp('(?:$|#)');
    
    var cells = getElementsByClass( 'tableContent1Left|tableContent2Left' );
    for( i=2; i<cells.length; i+=3 ) {
       var links = cells[i].getElementsByTagName('a');
       var link = links?((links.length>1)?links[1]:links[0]):null;
       if( link ) {
          // strip off any parameters on the end of the link
          var matches = link.textContent.match(/(^.*?)(?:\?|$)/);
          var shortLink = matches[1];
          var imgID = imgRegExp.exec(shortLink);
          if (!imgID) {
              imgID = galleryRegExp.exec(shortLink);
          }
          if (!imgID) {
            imgID = nicenameImageRegExp.exec(shortLink);
          }
          if( imgID ) {
             var host = imgID[1];
             // get the first match from the array that isn't null
             var ID = imgID[2]?imgID[2]:imgID[3];
             var ID = ID?ID:imgID[4];
             if (ID) {
               host = imgID[1];
               var thumb = document.createElement('img');
               // if ID starts with a / char, then it's a gallery ID
               if (ID.substr(0,1) == "/") {
                   ID = ID.substr(1);                // remove leading slash
                   var splitStr = ID.split("_");     // split id and key apart
                   thumb.setAttribute( 'src', 'http://' + host + 'photos/random.mg?AlbumID=' + splitStr[0] + '&Size=Tiny&AlbumKey=' + splitStr[1] + '&rand=1');
                   thumb.setAttribute( 'align', 'left' );
               } else {
                   thumb.setAttribute( 'src', 'http://'+host+'photos/'+ID+'-Ti-100.jpg');
                   thumb.setAttribute( 'align', 'left' );
               }
               thumb.setAttribute( 'border', '0' );
               thumb.setAttribute( 'alt', '' );
               var img = cells[i].getElementsByTagName('img');
               if( img && img[0] ) cells[i].removeChild( img[0] );
               cells[i].appendChild( thumb );
            }
          }
       }
    }
    
    --John
    HomepagePopular
    JFriend's javascript customizationsSecrets for getting fast answers on Dgrin
    Always include a link to your site when posting a question
  • AllenAllen Registered Users Posts: 10,013 Major grins
    edited January 17, 2010
    jfriend wrote:
    This is what I'm running with. It's been slightly fixed for nicenames, though there is still more that could be done. I am not supporting this script, just offering what I have "as is".
    ...
    Thanks John
    It looks like where your site is used is just a comment example of the
    nicename format. Any suggestion about putting in my own or even deleting
    those comments? Or just leave it as is.
    Al - Just a volunteer here having fun
    My Website index | My Blog
  • jfriendjfriend Registered Users Posts: 8,097 Major grins
    edited January 17, 2010
    Allen wrote:
    Thanks John
    It looks like where your site is used is just a comment example of the
    nicename format. Any suggestion about putting in my own or even deleting
    those comments? Or just leave it as is.
    All comments except the first six lines can be removed or left as is - it won't make any difference in functionality.
    --John
    HomepagePopular
    JFriend's javascript customizationsSecrets for getting fast answers on Dgrin
    Always include a link to your site when posting a question
  • AllenAllen Registered Users Posts: 10,013 Major grins
    edited January 17, 2010
    jfriend wrote:
    All comments except the first six lines can be removed or left as is - it won't make any difference in functionality.
    Changed the script and just waiting for it to take effect, thanks.
    Al - Just a volunteer here having fun
    My Website index | My Blog
  • AllenAllen Registered Users Posts: 10,013 Major grins
    edited April 8, 2010
    jfriend wrote:
    All comments except the first six lines can be removed or left as is - it won't make any difference in functionality.
    Upgraded to FF3.6 and now get some thumbs, only for non NiceName
    links though. Also only every third thumb shows, none in between.
    Something in code causing skipping two showing one skipping two
    showing one ..... ?
    Al - Just a volunteer here having fun
    My Website index | My Blog
  • jfriendjfriend Registered Users Posts: 8,097 Major grins
    edited April 8, 2010
    Allen wrote:
    Upgraded to FF3.6 and now get some thumbs, only for non NiceName
    links though. Also only every third thumb shows, none in between.
    Something in code causing skipping two showing one skipping two
    showing one ..... ?
    I'm sorry Allen, but I'm just not working on this script any more and not even using it myself. I find that with nicenames, I don't really need it anymore because I can see which gallery the hits are in from the URL and if I really want to know which image it is, I can just click on the link. What I needed most at a glance was which gallery and we mostly have that now with nicenames.
    --John
    HomepagePopular
    JFriend's javascript customizationsSecrets for getting fast answers on Dgrin
    Always include a link to your site when posting a question
  • AllenAllen Registered Users Posts: 10,013 Major grins
    edited September 12, 2010
    Now it has stopped working all together and no thumbs show. Anyone have an idea as to why?

    Maybe connection why liked photo thumbs don't show on FB?
    Al - Just a volunteer here having fun
    My Website index | My Blog
Sign In or Register to comment.