Options

Add thumbs to StatCounter with GreaseMonkey

2

Comments

  • Options
    ivarivar Registered Users Posts: 8,395 Major grins
    edited October 11, 2007
    Hey Nimai,

    I found two other types of links that don't appear to be working:
    path__ivar_s_photos_-20071011-223903.jpg

    path__ivar_s_photos_-20071011-224127.jpg

    Any chance on getting those in as well? mwink.gif
  • Options
    AllenAllen Registered Users Posts: 10,012 Major grins
    edited October 11, 2007
    None of mine work.:cry Any idea why the edit box don't popup under manage?
    Al - Just a volunteer here having fun
    My Website index | My Blog
  • Options
    ivarivar Registered Users Posts: 8,395 Major grins
    edited October 11, 2007
    Allen wrote:
    None of mine work.:cry Any idea why the edit box don't popup under manage?
    Did you associate it with a texteditor during setup?
  • Options
    NimaiNimai Registered Users Posts: 564 Major grins
    edited October 11, 2007
    ivar wrote:
    Hey Nimai,

    I found two other types of links that don't appear to be working:
    Any chance on getting those in as well? mwink.gif
    Updated. Give it a shot!

    I've put these scripts up on userscripts.org

    Maybe try installing from there??
  • Options
    ivarivar Registered Users Posts: 8,395 Major grins
    edited October 11, 2007
    Nimai wrote:
    Updated. Give it a shot!

    I've put these scripts up on userscripts.org

    Maybe try installing from there??
    w00t :ivar

    The magnify was back in the 'include' though, that I had to take out...
  • Options
    NimaiNimai Registered Users Posts: 564 Major grins
    edited October 11, 2007
    ivar wrote:
    The magnify was back in the 'include' though, that I had to take out...
    Got it.

    Allen - any luck?
  • Options
    ivarivar Registered Users Posts: 8,395 Major grins
    edited October 11, 2007
    Nimai wrote:
    Got it.

    Allen - any luck?
    Yeah, I think Allen is sorted thumb.gif

    I did notice that some links aren't working (anymore) though.

    It are the nickname.smugmug.com/gallery/XXXXXX/Y/ZZZZZZZZ links :cry
  • Options
    AllenAllen Registered Users Posts: 10,012 Major grins
    edited October 11, 2007
    Nimai wrote:
    Got it.

    Allen - any luck?
    Wh00t! Installed from the script page and working now.
    Thanks


    with Ivar's help of course. :D
    Al - Just a volunteer here having fun
    My Website index | My Blog
  • Options
    NimaiNimai Registered Users Posts: 564 Major grins
    edited October 11, 2007
    ivar wrote:
    Yeah, I think Allen is sorted thumb.gif

    I did notice that some links aren't working (anymore) though.

    It are the nickname.smugmug.com/gallery/XXXXXX/Y/ZZZZZZZZ links :cry
    Can you copy-paste a url that's not working in a PM? We'll get all these different formats eventually!!
    Thanks for all the help!
  • Options
    javier.rinaldijavier.rinaldi Registered Users Posts: 210 Major grins
    edited October 12, 2007
    Nimai,

    I finally got this running, at this PC at least, I can't get Greasemonkey running at home.
    I figured out that the script won't work on custom hosts, so changing the smugmug.\com to customhost.host helps.

    also, for the thumbs to show the external links need to be on for the galleries viewed.

    I also played around with your script, I used the .href property to get the url out of the <a> tags, using this (and the fact theat image # is always preceded by the # sysmbol I re-wrote some of your script. The only exception is when navigation pages are listed, where the url ends in #P1-15, this is also checked for and skipped when it happens.

    Here's is the code I'm using, feel free to try it yourself and see if any of the code helps you out.
    // ==UserScript==
    // @name          StatCounter SmugMug Thumbs
    // @namespace     http://nimai.smugmug.com/statcounterthumbs
    // @description   Adds thumbnails to the detailed view of StatCounter
    // @include       http://*.statcounter.com/project/standard/*
    // ==/UserScript==
    
    //--------------------------------------------------------------------------------
    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('[0-9]+');
    var pRegExp = new RegExp('P');
    var host = "http://www.jrinaldiphotography.com/";
    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){
           if(link.href != host){
            var imgID = imgRegExp.exec(link.href.split("#")[1]);
            var go = pRegExp.exec(link.href.split("#")[1]);
            if ( go ){}
            else{
                if(imgID){
                     var thumb = document.createElement('img');
                     thumb.setAttribute( 'src', host+'photos/'+imgID+'-Ti.jpg' );
                     thumb.setAttribute( 'alt', '' );
                     thumb.setAttribute( 'border', '0' );
                     thumb.setAttribute( 'align', 'right' );
                     cells[i].appendChild( thumb );
                    }
                }
            }
        }
    }
    
    Jav


    Creator of: SmugManager

    "There's no dark side or the moon, really. Matter of fact it's all dark..."
  • Options
    NimaiNimai Registered Users Posts: 564 Major grins
    edited October 12, 2007
    Sweet, Javi!
    I thought that images id's were always preceded by a # too, but in the there are some styles that aren't, like in ivar's first reply. I'm glad this gave you a good starting point to get something that works for you, though. You're right about the custom host thing - there's just no way around having to customize that.
  • Options
    TrueBobTrueBob Registered Users Posts: 10 Big grins
    edited October 29, 2007
    ivar wrote:
    I had to change the include from http://*.statcounter.com/project/standard/magnify.php?* to http://*.statcounter.com/project/standard/* to work. I don't have the magnify in my url? It may be because I have multiple projects set up?

    Hmmm, well, I may be adding to many new things at once. Added Firefox last week, added Grease Monkey to it today, installed the script and edited the namespace (for Include.. use the 2nd choice that Ivar has above) but I'm not seeing any thumbnails in my Statcounter Project).

    Greasemonkey shows enabled. Am I missing a step or three perhaps?ne_nau.gif

    Bob Buckland ?:-)

    http://truebob.smugmug.com
  • Options
    NimaiNimai Registered Users Posts: 564 Major grins
    edited October 29, 2007
    TrueBob wrote:
    Hmmm, well, I may be adding to many new things at once. Added Firefox last week, added Grease Monkey to it today, installed the script and edited the namespace (for Include.. use the 2nd choice that Ivar has above) but I'm not seeing any thumbnails in my Statcounter Project).

    Greasemonkey shows enabled. Am I missing a step or three perhaps?ne_nau.gif

    Bob Buckland ?:-)

    http://truebob.smugmug.com
    Um... let's see. I guess you could add an alert('Hello?'); line to the script and see if it's even getting invoked properly. (I thought I'd changed that @include on my version of the script too... ?)
  • Options
    TrueBobTrueBob Registered Users Posts: 10 Big grins
    edited October 30, 2007
    Nimai wrote:
    Um... let's see. I guess you could add an alert('Hello?'); line to the script and see if it's even getting invoked properly. (I thought I'd changed that @include on my version of the script too... ?)
    Hi Nimai.

    Thank you for that idea. Once I learned how to add the alert <g> (I put it after the 'comment' lines but before the 'function' lines) I went to Statcounter.com went into my project and the 'hello' alert popped up, but no thumbnails in the 'Recent Pageloads' link from the Statcounter Navbar.
    Is that where I should be seeing things?

    Bob Buckland ?:-)
    http://TrueBob.smugmug.com
  • Options
    NimaiNimai Registered Users Posts: 564 Major grins
    edited October 31, 2007
    TrueBob wrote:
    but no thumbnails in the 'Recent Pageloads' link from the Statcounter Navbar.
    Is that where I should be seeing things?
    You know, I bet it could be made to work in Recent Pageloads but I had only tested it with Recent Visitor Activity, when you click on the magnifying glass to see the details.
  • Options
    TrueBobTrueBob Registered Users Posts: 10 Big grins
    edited October 31, 2007
    Nimai wrote:
    You know, I bet it could be made to work in Recent Pageloads but I had only tested it with Recent Visitor Activity, when you click on the magnifying glass to see the details.

    I must be missing something to set this up, as it doesn't work in any of the screens including magnify after Recent Visitor Activity. I do get the 'hello' dialog popup, just not any pictures. headscratch.gif Any clues, or a walkthrough of setting it up and checking to see where I might be going wrong?

    Bob Buckland ?:-)
  • Options
    NimaiNimai Registered Users Posts: 564 Major grins
    edited November 2, 2007
    TrueBob wrote:
    I must be missing something to set this up, as it doesn't work in any of the screens including magnify after Recent Visitor Activity. I do get the 'hello' dialog popup, just not any pictures. headscratch.gif Any clues, or a walkthrough of setting it up and checking to see where I might be going wrong?

    Bob Buckland ?:-)
    Well, if you're getting a Hello, it's being triggered.
    I guess you could start "caveman debugging" and adding things like alert(cells.length); above the line with the for loop, etc. See what the code's doing. There are a few if's inside the for loop, which might never be entered, for whatever reason. If you do put an alert inside the for loop, I'd recommend adding a break; at the bottom of the loop so that you don't get annoyed with alert after alert.
    That's odd that you'd be having probs...
  • Options
    aktseaktse Registered Users Posts: 1,928 Major grins
    edited December 17, 2007
    First of all, I LOVE this script! thumb.gif

    However, I recently started using a custom domain and I don't see any of the thumbnails anymore when people go through my custom domain. I still get it when they enter the site via the smugmug url.

    Any ideas?

    And thanks again.
  • Options
    jchinjchin Registered Users Posts: 713 Major grins
    edited December 19, 2007
    Does this work for customized domain names?
    Johnny J. Chin ~ J. Chin Photography
    FacebookFlickrSmugMug
    SmugMug referral coupon code: ix3uDyfBU6xXs
    (use this for a discount off your SmugMug subscription)
  • Options
    AllenAllen Registered Users Posts: 10,012 Major grins
    edited December 19, 2007
    jchin wrote:
    Does this work for customized domain names?
    I have both showing, the custom and the nickname.
    Al - Just a volunteer here having fun
    My Website index | My Blog
  • Options
    aktseaktse Registered Users Posts: 1,928 Major grins
    edited December 19, 2007
    Allen wrote:
    I have both showing, the custom and the nickname.
    THen I must be doing something wrong...
    from the smugmug domian:
    234148688-M.jpg

    from my custom domain:
    234148674-M.jpg

    I installed the script using the provided linky and I looked at this from two dffferent computers.

    Is my custom domain set up wrong?

    Any other ideas? ne_nau.gif
  • Options
    jfriendjfriend Registered Users Posts: 8,097 Major grins
    edited May 21, 2008
    Is this greasemonkey script supposed to still work now that Smugmug has imageIDs and imageKeys? Does it need to be updated? When I try it, I only see a few thumbs. Most of them don't show.
    --John
    HomepagePopular
    JFriend's javascript customizationsSecrets for getting fast answers on Dgrin
    Always include a link to your site when posting a question
  • Options
    JuliaJulia Registered Users Posts: 157 Major grins
    edited July 5, 2008
    Bumping this up... I loved this script, and like jfriend said, it doesn't work now with the new security changes. Any chance it can be updated? :Diloveyou.gif
  • Options
    mteichermteicher Registered Users Posts: 72 Big grins
    edited July 9, 2008
    Stat Counter redux
    Is this code still vald after all the changes made recently to smugmug ??
    Nimai wrote:
    Here's a GreaseMonkey script that will add thumbnails to the detail pages of StatCounter, for you StatCounter hawks.

    Makes it look like this, so you won't have to click to see what's being looked at! thumb.gif
    smugstatthumbsax3.jpg

    Here's the code, or install straight from my scripts on userscripts.org
    // ==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==
     
    //--------------------------------------------------------------------------------
    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 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 ) {
          var imgID = imgRegExp.exec( link.textContent );
          if( imgID ) {
             var host = imgID[1];
             var ID = imgID[2]?imgID[2]:imgID[3];
             ID = ID?ID:imgID[4];
             var thumb = document.createElement('img');
             thumb.setAttribute( 'src', 'http://'+host+'photos/'+ID+'-Ti.jpg' );
             thumb.setAttribute( 'alt', '' );
             thumb.setAttribute( 'border', '0' );
             thumb.setAttribute( 'align', 'right' );
             var img = cells[i].getElementsByTagName('img');
             if( img && img[0] ) cells[i].removeChild( img[0] );
             cells[i].appendChild( thumb );
          }
       }
    }
    
    I haven't tried this with anyone else's StatCounter and SmugMug accounts, so if you do use it and find any problems, or just want to give it a thumbs-up, please respond to this thread.
    Enjoy!
    Mark Teicher
    Principle Photographer/Co-Founder
    Body Bumpers, LLC
    PH: 717 918 1262
    Fax: 831 480 5873
    url: www.body-bumpers.com
    email: mteicher@body-bumpers.com
  • Options
    jfriendjfriend Registered Users Posts: 8,097 Major grins
    edited August 11, 2008
    I've made some modifications to this script so that it works much better with Smugmug image keys and I am now getting thumbs in my StatCounter report for most pages again. There are still some URLs that I haven't fixed yet and there are some URLs that it will never work on (the imageKey isn't in the page URL so it isn't in the StatCounter report).

    If anyone wants to fix their script, let me know and I'll figure out how to post my changes.
    --John
    HomepagePopular
    JFriend's javascript customizationsSecrets for getting fast answers on Dgrin
    Always include a link to your site when posting a question
  • Options
    NimaiNimai Registered Users Posts: 564 Major grins
    edited August 12, 2008
    Guess I need to check in here more often!

    JFriend: If you want to send me your updated version, I'd love to update the original userscripts repo - and give you loads of credit too, of course!
    Things sure have gotten tricky with the new image keys. Let's hope this works out!

    Thanks.
  • Options
    jfriendjfriend Registered Users Posts: 8,097 Major grins
    edited August 12, 2008
    Nimai wrote:
    Guess I need to check in here more often!

    JFriend: If you want to send me your updated version, I'd love to update the original userscripts repo - and give you loads of credit too, of course!
    Things sure have gotten tricky with the new image keys. Let's hope this works out!

    Thanks.

    I've got it working so far for all gallery, keyword and popular URLs that I've found so far that contain both an imageID and imageKey (which is quite a few different forms of URLs). I'm still working on it some more today to see if there's something useful I can do for some of the other URLs that get page hits. I will send you the file when I'm done testing and working on it, probably some time tomorrow. Overall the statcounter report is now a lot, lot, lot more useful to me.
    --John
    HomepagePopular
    JFriend's javascript customizationsSecrets for getting fast answers on Dgrin
    Always include a link to your site when posting a question
  • Options
    NimaiNimai Registered Users Posts: 564 Major grins
    edited August 13, 2008
    bowdown.gif Thank you so much!

    I've updated the code on userscripts.org and in the original thread post.
  • Options
    AllenAllen Registered Users Posts: 10,012 Major grins
    edited August 13, 2008
    Thnaks, most of the thumbs are showing now.
    Al - Just a volunteer here having fun
    My Website index | My Blog
  • Options
    jfriendjfriend Registered Users Posts: 8,097 Major grins
    edited August 13, 2008
    Allen wrote:
    Thnaks, most of the thumbs are showing now.

    I haven't found a way to make all the thumbs work, but I think most that can work are working now. It really makes my statcounter diplay a lot more useful.

    Smugmug still has some URLs (like what you get when you ask for the next image to be displayed : http://jfriend.smugmug.com/gallery/5608869_vwzCG#344291068) that don't have the imageKey in them. Since all StatCounter records is the URL, I can't make a thumb from the URL without an imageKey in the URL. There are also some gallery URLs without the galleryKey.

    So, for now, there are still some URLs that don't display thumbs. But, I'm getting most of them now. If you see any URLs that appear to have an imageID and imageKey in them, just post that URL here and I'll modify the script to fix it.
    --John
    HomepagePopular
    JFriend's javascript customizationsSecrets for getting fast answers on Dgrin
    Always include a link to your site when posting a question
Sign In or Register to comment.