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 );
}
}
}
}
}
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.
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?
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?
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... ?)
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?
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.
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. Any clues, or a walkthrough of setting it up and checking to see where I might be going wrong?
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. 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...
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.
Johnny J. Chin ~ J. Chin Photography Facebook ♦ Flickr ♦ SmugMug
SmugMug referral coupon code: ix3uDyfBU6xXs
(use this for a discount off your SmugMug subscription)
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.
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!
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!
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.
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!
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.
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.
Comments
I found two other types of links that don't appear to be working:
Any chance on getting those in as well?
www.ivarborst.nl & smugmug
My Website index | My Blog
www.ivarborst.nl & smugmug
I've put these scripts up on userscripts.org
Maybe try installing from there??
The magnify was back in the 'include' though, that I had to take out...
www.ivarborst.nl & smugmug
Allen - any luck?
I did notice that some links aren't working (anymore) though.
It are the nickname.smugmug.com/gallery/XXXXXX/Y/ZZZZZZZZ links :cry
www.ivarborst.nl & smugmug
Thanks
with Ivar's help of course.
My Website index | My Blog
Thanks for all the help!
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.
Creator of: SmugManager
"There's no dark side or the moon, really. Matter of fact it's all dark..."
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.
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?
Bob Buckland ?:-)
http://truebob.smugmug.com
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
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. Any clues, or a walkthrough of setting it up and checking to see where I might be going wrong?
Bob Buckland ?:-)
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...
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.
Facebook ♦ Flickr ♦ SmugMug
SmugMug referral coupon code: ix3uDyfBU6xXs
(use this for a discount off your SmugMug subscription)
My Website index | My Blog
from the smugmug domian:
from my custom domain:
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?
Homepage • Popular
JFriend's javascript customizations • Secrets for getting fast answers on Dgrin
Always include a link to your site when posting a question
Is this code still vald after all the changes made recently to smugmug ??
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
If anyone wants to fix their script, let me know and I'll figure out how to post my changes.
Homepage • Popular
JFriend's javascript customizations • Secrets for getting fast answers on Dgrin
Always include a link to your site when posting a question
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.
Homepage • Popular
JFriend's javascript customizations • Secrets for getting fast answers on Dgrin
Always include a link to your site when posting a question
I've updated the code on userscripts.org and in the original thread post.
My Website index | My Blog
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.
Homepage • Popular
JFriend's javascript customizations • Secrets for getting fast answers on Dgrin
Always include a link to your site when posting a question