PDA

View Full Version : Add thumbs to StatCounter with GreaseMonkey


Nimai
Oct-10-2007, 08:59 AM
*** Update code August 13, 2008 thanks to JFriend ***

Here's a GreaseMonkey script that will add thumbnails to the detail pages of StatCounter (http://www.statcounter.com), for you StatCounter hawks.

Makes it look like this, so you won't have to click to see what's being looked at! :thumb
http://img227.imageshack.us/img227/8063/smugstatthumbsax3.jpg

Here's the code, or install straight from my scripts on userscripts.org (http://userscripts.org/users/35458;scripts)
// ==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==


// Update on Aug 11, 200 by John Friend
// 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('(^[^/]+/)(?: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]+$))');

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) {
imgID = galleryRegExp.exec( link.textContent );
}
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.jpg');
thumb.setAttribute( 'align', 'right' );
}
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 );
}
}
}
}

// sub-expressions
// 342986767_gsLLX [0-9]+_[0-9a-zA-Z]+ // image ID and key
// 342986767_gsLLX at end ([0-9]+_[0-9a-zA-Z]+)$ // image ID and key at end of the URL
// http://jfriend.smugmug.com/ ^http://[^/]+/ // http://domain
// jfriend.smugmug.com/ ^[^/]+/ // domain
// gallery/5589651_rU4bA gallery/[0-9]+_[0-9a-zA-Z]+ // gallery number
// gallery/5589651_rU4bA/1/342986767_gsLLX or
// gallery/5589651_rU4bA/3/342986476_YYeu6/Medium or
// gallery/5589651_rU4bA#342971777_3GE8Q or
// gallery/5589651_rU4bA#342992308_jm3Wg-A-LB or
// gallery/879690_N8UHS/2/66770280_dRonw#P-2-25 gallery/[0-9]+_[0-9a-zA-Z]+(?:#|/[0-9]+/)([0-9]+_[0-9a-zA-Z]+) // gallery/gallery_number imageID_imageKey
// gallery/5589651_rU4bA#P-4-12 gallery(/[0-9]+_[0-9a-zA-Z]+)#P[\-0-9]+$ // just a gallery ID with gallery Key, we include leading slash on matched result so we can tell it's a gallery ID in the code
// gallery/5589651_rU4bA gallery(/[0-9]+_[0-9a-zA-Z]+)$

// Way to get random thumb for a gallery: http://jfriend.smugmug.com/photos/random.mg?AlbumID=5646334&Size=Tiny&AlbumKey=jFXoe&rand=1267


//Supported URL types:
// http://jfriend.smugmug.com/gallery/5589651_rU4bA/3/342986476_YYeu6/Medium
// http://jfriend.smugmug.com/gallery/5589651_rU4bA#342971777_3GE8Q
// http://jfriend.smugmug.com/gallery/5589651_rU4bA/1/342986767_gsLLX
// http://jfriend.smugmug.com/gallery/5589651_rU4bA#342992308_jm3Wg-A-LB
// http://jfriend.smugmug.com/gallery/879690_N8UHS/2/66770280_dRonw#P-2-25
// http://jfriend.smugmug.com/popular/#66768822_mLumi
// http://jfriend.smugmug.com/popular/1/66770280_dRonw#39934670_buaG8
// http://jfriend.smugmug.com/popular/8/66769006_dcwFT
// http://jfriend.smugmug.com/popular/1/66770280_dRonw/Large
// http://jfriend.smugmug.com/popular/#66769006_dcwFT-XL-LB
// http://www.moonriverphotography.com/date/2008-01-1/2008-12-1#245318676_gd5X5
// http://www.moonriverphotography.com/date/2008-01-1/2008-12-1#300157250_XXXTa-A-LB
// http://www.moonriverphotography.com/keyword/fine+art#342192111_dsYBa
// http://www.moonriverphotography.com/keyword/fine+art#2332717_QgjEK-A-LB
// http://jfriend.smugmug.com/gallery/5589651_rU4bA#P-4-12


// URL types that can't work except on old galleries because there's no image key
// http://jfriend.smugmug.com/gallery/5575096_C3nQ5#342362737
// http://jfriend.smugmug.com/popular/#66768822



// URL types that can't work because there's no imageID
// http://jfriend.smugmug.com/gallery/5589651_rU4bA/1
// http://jfriend.smugmug.com/gallery/5571152_5ARMa#P-6-12
// http://jfriend.smugmug.com/gallery/5589651_rU4bA
// http://jfriend.smugmug.com/Kenya
// http://jfriend.smugmug.com
// http://jfriend.smugmug.com/popular/#P-6-12
// http://www.moonriverphotography.com/keyword/fine+art#P-2-25
//

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!

ivar
Oct-10-2007, 09:14 AM
:bow Very cool, works fine :thumb I just changed the include link to work for my pages.

http://myskitch.com/ivar/path__ivar_s_photos_-20071010-180910.jpg

Any chance you can get it to work with the links to the singleImage style and keywords as well? :wink
http://myskitch.com/ivar/path__ivar_s_photos_-20071010-181009.jpghttp://myskitch.com/ivar/path__ivar_s_photos_-20071010-200407.jpg

Allen
Oct-10-2007, 10:16 AM
:bow Very cool, works fine :thumb I just changed the include link to work for my pages.

Ok, where's this include link and how do we apply it?:D

Wow! That's realy neat Nimai. Thanks.

Nimai
Oct-10-2007, 11:20 AM
You shouldn't need to change anything. I tried to avoid any specific reference to my SmugMug account in the script, except for the namespace, which I think is only used for unique-ification of scripts.
Glad to see there's some interest in this! :D

I'll reply here when I get popular and keyword links working too.

Nimai
Oct-10-2007, 11:46 AM
Some RegExp tweaks, and now it should work for popular and keyword hits too.

Code has been updated in the initial post. Thanks for the suggestion!

ivar
Oct-10-2007, 11:56 AM
You shouldn't need to change anything. I tried to avoid any specific reference to my SmugMug account in the script, except for the namespace, which I think is only used for unique-ification of scripts.
Glad to see there's some interest in this! :D
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?

ivar
Oct-10-2007, 11:57 AM
Some RegExp tweaks, and now it should work for popular and keyword hits too.

Code has been updated in the initial post. Thanks for the suggestion!
popular :barb
keywords :cry

Nimai
Oct-10-2007, 12:11 PM
popular :barb
keywords :cryHaha- nice.

Well, I went ahead just now and changed the @include to take out the magnify. As for the keywords... Mine are showing up like this:

keyword/2007-cheerleading-hcms/1/200166550/Medium

I see your's are showing up with a # before the image id.

keyword/naples#109172182

I tried to make the RegExp accomodating of both, but I didn't have a #-style page to test against... I'll keep you posted.

Nimai
Oct-10-2007, 12:19 PM
ivar - could you try the code that's up there now? There was about a 60 second window when I first updated the code, then immediately found I needed to change something, and updated it again hoping maybe no one noticed. ;) Maybe you got it in that time!
I just tried the script with a URL from your gallery, and I got a thumb, so I'm hoping it works now.

ivar
Oct-10-2007, 12:19 PM
but I didn't have a #-style page to test against... You should now :wink

ivar
Oct-10-2007, 12:23 PM
ivar - could you try the code that's up there now? There was about a 60 second window when I first updated the code, then immediately found I needed to change something, and updated it again hoping maybe no one noticed. ;) Maybe you got it in that time!
I just tried the script with a URL from your gallery, and I got a thumb, so I'm hoping it works now.:clap :clap
http://myskitch.com/ivar/path__ivar_s_photos_-20071010-212009.jpg

Nice work!

Allen
Oct-10-2007, 12:30 PM
Guessing links in before adding js wil not have thumbs.
Waiting is hard.:D


And just updated to latest js.

Allen
Oct-10-2007, 12:31 PM
Nope, none showing Ivar. Must be something I'm not doing.

ivar
Oct-10-2007, 12:32 PM
Guessing links in before adding js wil not have thumbs.
Waiting is hard.:D


And just updated to latest js.Greasemonkey (https://addons.mozilla.org/en-US/firefox/addon/748) :deal

Allen
Oct-10-2007, 12:34 PM
Greasemonkey (https://addons.mozilla.org/en-US/firefox/addon/748) :deal
Guess I don't understand any of this, gota install it huh?

Edit: installed and enabled, now what? wait? :D

ivar
Oct-10-2007, 12:35 PM
Guess I don't understand any of this, gota install it huh?Yep, install it, it's a firefox addon.

It lives in tools menu.
Add a new script, use the above code :thumb

Allen
Oct-10-2007, 12:39 PM
Yep, install it, it's a firefox addon.

It lives in tools menu.
Add a new script, use the above code :thumb
Oh! I put that in my js, not right? Need to add new GM user script?
Not sure how to do that.

ivar
Oct-10-2007, 12:42 PM
Oh! I put that in my js, not right?right, not right :D

Need to add new GM user script? Not sure how to do that.In Firefox, Tools>Greasemonkey>New user script

The first time you may need to associate GM with a texteditor. Use notepad (windows) or texteditor (mac) or similar. It will automatically ask for this if I remember correctly.

Allen
Oct-10-2007, 12:48 PM
right, not right :D

In Firefox, Tools>Greasemonkey>New user script

The first time you may need to associate GM with a texteditor. Use notepad (windows) or texteditor (mac) or similar. It will automatically ask for this if I remember correctly.
" associate GM with a texteditor" lost me

I assume I go to the statcounter page and pick "new user script" so it's
assocaited with that page or site? The magnifiy page or summary page?

The popup box has name, namespace, desc, includes (has SC site address) and exclude. Where's script go?

ivar
Oct-10-2007, 12:52 PM
I assume I go to the statcounter page and pick "new user script" so it's assocaited with that page or site? The magnifiy page or summary page?Nope, not needed, the idea is that it will only work for the pages that you specify under 'include' :thumb


The popup box has name, namespace, desc, includes (has SC site address) and exclude. Where's script go?first enter all that stuff.

If you don't get a texteditor popping up, go to tools>greasmonkey>manage user scripts>edit

Allen
Oct-10-2007, 01:01 PM
Nope, not needed, the idea is that it will only work for the pages that you specify under 'include' :thumb


first enter all that stuff.

If you don't get a texteditor popping up, go to tools>greasmonkey>manage user scripts>edit
Ok, saved text file and filled in info. Linked saved file in popup. What pages do I include? Recent Visitor Activity page? Shows in manage window now.

ivar
Oct-10-2007, 01:02 PM
Ok, saved text file and filled in info. Linked saved file in popup. What pages do I include? Recent Visitor Activity page? Shows in manage window now.This should be the include page:
http://*.statcounter.com/project/standard/*

Allen
Oct-10-2007, 01:13 PM
This should be the include page:
http://*.statcounter.com/project/standard/*
Now if can't find the page.:scratch Do I need this maybe?

http://*my3.statcounter.com/project/*

what's in there now but no thumbs
http://*my3.statcounter.com/project/standard/*

Nimai
Oct-10-2007, 02:28 PM
Now if can't find the page.:scratch Do I need this maybe?

http://*my3.statcounter.com/project/*

what's in there now but no thumbs
http://*my3.statcounter.com/project/standard/*The include line determines when the script will be run. If the URL page just loaded matches the include, GreaseMonkey will run the script. The * are wild. So, http://*.statcounter.com/project/standard/* should work. What's your stat counter URL look like when you're looking at the details.

Allen
Oct-10-2007, 02:32 PM
The include line determines when the script will be run. If the URL page just loaded matches the include, GreaseMonkey will run the script. The * are wild. So, http://*.statcounter.com/project/standard/* should work. What's your stat counter URL look like when you're looking at the details.
I now have the one you entered above.

http://*.statcounter.com/project/standard/*

Realized the wild * and took out the my3 or whatever it change too.

But still not working. What is the namespace?

Nimai
Oct-10-2007, 02:44 PM
I now have the one you entered above.

http://*.statcounter.com/project/standard/*

Realized the wild * and took out the my3 or whatever it change too.

But still not working. What is the namespace?The namespace is simply to uniquely identify a script. No one should use namespaces that they don't own, so this should make the script namespace unique.

Maybe there's more here (http://diveintogreasemonkey.org/helloworld/metadata.html) that might help?

Allen
Oct-10-2007, 02:54 PM
The namespace is simply to uniquely identify a script. No one should use namespaces that they don't own, so this should make the script namespace unique.

Maybe there's more here (http://diveintogreasemonkey.org/helloworld/metadata.html) that might help?
Oops, should of changed this to me, right?

// @namespace http://nimai.smugmug.com/statcounterthumbs

How do I remove what I have and start over? I created a new one but the
text file popup didn't show.

javier.rinaldi
Oct-10-2007, 02:58 PM
No joy for me either.

ivar
Oct-10-2007, 03:01 PM
Try this:

In firefox go to Tools > Greasemonkey > Manage User Scripts
Select the script and hit 'edit'.

In the window that will open, make sure that the code is exactly as in Nimai's first post, no changes. Save it.

Check to make sure that the include is correctly set up.

That should do it.

Allen
Oct-10-2007, 03:07 PM
Try this:

In firefox go to Tools > Greasemonkey > Manage User Scripts
Select the script and hit 'edit'.

In the window that will open, make sure that the code is exactly as in Nimai's first post, no changes. Save it.

Check to make sure that the include is correctly set up.

That should do it.
I get no window opening after clicking edit.:scratch

devbobo
Oct-10-2007, 03:47 PM
Very cool Nimai :clap:clap

ivar
Oct-11-2007, 01:45 PM
Hey Nimai,

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

http://myskitch.com/ivar/path__ivar_s_photos_-20071011-224127.jpg

Any chance on getting those in as well? :wink

Allen
Oct-11-2007, 01:59 PM
None of mine work.:cry Any idea why the edit box don't popup under manage?

ivar
Oct-11-2007, 02:13 PM
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?

Nimai
Oct-11-2007, 02:18 PM
Hey Nimai,

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

I've put these scripts up on userscripts.org (http://userscripts.org/users/35458;scripts)

Maybe try installing from there??

ivar
Oct-11-2007, 02:22 PM
Updated. Give it a shot!

I've put these scripts up on userscripts.org (http://userscripts.org/users/35458;scripts)

Maybe try installing from there??w00t :ivar

The magnify was back in the 'include' though, that I had to take out...

Nimai
Oct-11-2007, 02:45 PM
The magnify was back in the 'include' though, that I had to take out...Got it.

Allen - any luck?

ivar
Oct-11-2007, 03:01 PM
Got it.

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

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

It are the nickname.smugmug.com/gallery/XXXXXX/Y/ZZZZZZZZ links :cry

Allen
Oct-11-2007, 03:03 PM
Got it.

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


with Ivar's help of course. :D

Nimai
Oct-11-2007, 07:34 PM
Yeah, I think Allen is sorted :thumb

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

It are the nickname.smugmug.com/gallery/XXXXXX/Y/ZZZZZZZZ links :cryCan 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!

javier.rinaldi
Oct-12-2007, 06:39 AM
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 );
}
}
}
}
}

Nimai
Oct-12-2007, 02:38 PM
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.

TrueBob
Oct-28-2007, 11:01 PM
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?:dunno

Bob Buckland ?:-)

http://truebob.smugmug.com

Nimai
Oct-29-2007, 08:01 AM
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?:dunno

Bob Buckland ?:-)

http://truebob.smugmug.comUm... 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... ?)

TrueBob
Oct-30-2007, 05:55 AM
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

Nimai
Oct-31-2007, 06:37 AM
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.

TrueBob
Oct-31-2007, 01:44 PM
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. :scratch Any clues, or a walkthrough of setting it up and checking to see where I might be going wrong?

Bob Buckland ?:-)

Nimai
Nov-02-2007, 09:31 AM
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. :scratch 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...

aktse
Dec-17-2007, 07:40 AM
First of all, I LOVE this script! :thumb

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.

jchin
Dec-19-2007, 03:39 AM
Does this work for customized domain names?

Allen
Dec-19-2007, 05:30 AM
Does this work for customized domain names?
I have both showing, the custom and the nickname.

aktse
Dec-19-2007, 05:18 PM
I have both showing, the custom and the nickname.
THen I must be doing something wrong...
from the smugmug domian:
http://aktse.smugmug.com/photos/234148688-M.jpg

from my custom domain:
http://aktse.smugmug.com/photos/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? :dunno

jfriend
May-21-2008, 02:43 PM
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.

Julia
Jul-05-2008, 07:49 PM
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? :D :lust

mteicher
Jul-09-2008, 03:53 AM
Is this code still vald after all the changes made recently to smugmug ??

Here's a GreaseMonkey script that will add thumbnails to the detail pages of StatCounter (http://www.statcounter.com), for you StatCounter hawks.

Makes it look like this, so you won't have to click to see what's being looked at! :thumb
http://img227.imageshack.us/img227/8063/smugstatthumbsax3.jpg

Here's the code, or install straight from my scripts on userscripts.org (http://userscripts.org/users/35458;scripts)
// ==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!

jfriend
Aug-11-2008, 08:02 PM
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.

Nimai
Aug-12-2008, 12:40 PM
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.

jfriend
Aug-12-2008, 12:45 PM
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.

Nimai
Aug-13-2008, 05:59 AM
:bow Thank you so much!

I've updated the code on userscripts.org and in the original thread post.

Allen
Aug-13-2008, 06:01 PM
Thnaks, most of the thumbs are showing now.

jfriend
Aug-13-2008, 06:14 PM
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 (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.

rsirota
Aug-26-2008, 02:13 PM
Am I missing something?

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

I see nothing...

Thanks...

jfriend
Aug-26-2008, 02:48 PM
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:
http://myskitch.com/ivar/path__ivar_s_photos_-20071010-180910.jpg

rsirota
Aug-26-2008, 04:20 PM
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:
http://myskitch.com/ivar/path__ivar_s_photos_-20071010-180910.jpg

Nothing just get text.. It is a custom domain does that matter?

jfriend
Aug-26-2008, 04:33 PM
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 (http://userscripts.org/scripts/show/12943).

rsirota
Aug-26-2008, 04:57 PM
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 (http://userscripts.org/scripts/show/12943).

Got it working.. .One question though, can it be made to work with the "Recent Visitor Activity" page too?

jfriend
Aug-26-2008, 05:55 PM
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?

rsirota
Aug-26-2008, 05:58 PM
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...

jfriend
Aug-26-2008, 06:09 PM
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.

rsirota
Aug-26-2008, 06:13 PM
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...

Allen
Aug-26-2008, 10:44 PM
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.