Jump to content

Temporary GreaseMonkey fix for My Profile page


Chrysalides
Followers 4

Recommended Posts

In Firefox, I see that in My Profile, "Visit Log" takes two lines for every single cache listing that I found. That's pretty annoying to me and introduces a lot of white space.

 

Rather than mess with table width, I chose to do a quick and dirty hack in Greasemonkey, to replace "Visit Log" with "Log". Result : about 30% less white space in the page.

 

I'm including source code here so that you know nothing infernal is being done to your machine. Let me know if you need step by step instructions on how to install it. Hopefully this will be fixed soon by Groundspeak and the script unnecessary.

 

// ==UserScript==
// @name		   My Profile Fix
// @namespace	  chrysalides
// @description	Change "Visit Log" (2 lines) to "Log"
// @include		http://www.geocaching.com/my/
// ==/UserScript==

document.body.innerHTML= document.body.innerHTML.replace(/Visit Log/g,"Log");

Link to comment

Good fix, thanks.

 

I added to your script to make some additional changes. Still some more to do, but shortening up some stuff makes the longer cache names fit better.

 

Several of these lines would need to be changed as I have hard coded my user name and the local state names I want shortened.

 

// ==UserScript==

// @name My Profile Fix

// @namespace chrysalides

// @description Change various items on MyProfile page

// @include http://www.geocaching.com/my/

// ==/UserScript==

document.body.innerHTML= document.body.innerHTML.replace(/Visit Log/g,"Visit Log");

document.body.innerHTML= document.body.innerHTML.replace(/Right Wing Wacko</g,"You<");

document.body.innerHTML= document.body.innerHTML.replace(/Traditional Cache/g,"Traditional");

document.body.innerHTML= document.body.innerHTML.replace(/Event Cache/g,"Event");

document.body.innerHTML= document.body.innerHTML.replace(/Letterbox Hybrid/g,"Letterbox");

document.body.innerHTML= document.body.innerHTML.replace(/Travel Bug Dog Tag/g,"Travel Bug");

document.body.innerHTML= document.body.innerHTML.replace(/Arizona/g,"AZ");

document.body.innerHTML= document.body.innerHTML.replace(/Washington/g,"WA");

document.body.innerHTML= document.body.innerHTML.replace(/Oregon/g,"OR");

document.body.innerHTML= document.body.innerHTML.replace(/Idaho/g,"ID");

document.body.innerHTML= document.body.innerHTML.replace(/British Columbia/g,"BC");

Link to comment
I added to your script to make some additional changes. Still some more to do, but shortening up some stuff makes the longer cache names fit better.

Nice - thank you!

 

I'll see if I can crank out a cleaner version later today if Groundspeak has not changed their stuff. The problem with the innerHTML method is that non text elements are affected as well. Probably not an issue here, but with more things being changed, the potential for error increases.

Link to comment

Nice.

 

If you also make this change to your userContent.css file it removes a lot of the white space in between lines of that table (and some other tables):

 

@-moz-document domain(geocaching.com) {

.Table {line-height: 100% ! important; }

}

 

Details on what this file is: http://www.mozilla.org/unix/customizing.html

 

Basically find userContent-example.css, rename it to userContent.css, paste the above in, close and restart firefox.

 

I also added this line to the GM script:

document.body.innerHTML= document.body.innerHTML.replace(/couldn't find/g,"DNFed");

document.body.innerHTML= document.body.innerHTML.replace(/District of Columbia/g,"D.C.");

 

I didn't realize how easy it is to do a text replace with greasemonkey... I'll have to remember this for other sites, too. Very slick.

 

I'll see if I can crank out a cleaner version later today if Groundspeak has not changed their stuff. The problem with the innerHTML method is that non text elements are affected as well. Probably not an issue here, but with more things being changed, the potential for error increases.

 

Oh, interesting. So if the site used 'Visit Log' as part of an element's id, this script would change that and hose things up?

Edited by rob3k
Link to comment
If you also make this change to your userContent.css file ...

Instead of mucking around with files, you should try the Stylish extension for Firefox. Makes it easy to make CSS changes from within the browser, and also makes it easy to share those changes.

 

Just grabbed it and it does make it a lot easier to apply CSS changes.

 

Also, thanks for getting your GM scripts updated immediately, I use them every day. :lol:

Link to comment
I added to your script to make some additional changes. Still some more to do, but shortening up some stuff makes the longer cache names fit better.

Nice - thank you!

 

I'll see if I can crank out a cleaner version later today if Groundspeak has not changed their stuff. The problem with the innerHTML method is that non text elements are affected as well. Probably not an issue here, but with more things being changed, the potential for error increases.

 

Here is a little add in for GreaseMonkey to fix the line height.

 

// ==UserScript==

// @name Geocaching.com/my

// @namespace http://www.geocaching.com/my

// @include http://www.geocaching.com/my/default.aspx

// ==/UserScript==

 

function addGlobalStyle(css) {

var head, style;

head = document.getElementsByTagName('head')[0];

if (!head) { return; }

style = document.createElement('style');

style.type = 'text/css';

style.innerHTML = css;

head.appendChild(style);

}

 

addGlobalStyle(

'table.Table th, table.Table td {' +

'padding:0.2em !important;' +

'}' +

'p, #Content h1, h2, h3, h4, h5, h6, fieldset, .Spacing {' +

'margin-top:0.5em;' +

'}');

 

-Nathan

Link to comment

I have some code to reduce the number of Profile Widgets to the right of the screen. Unfortunately I'm not experienced enough with Javascript to make this configurable for now, so to customize it, you'll need to edit code. But it should be straightforward enough.

 

What this script does is go through the list of Profile Widgets, and remove the stat bar, your GPS, and Geocaching with Twitter section. If you want those sections, move that line to the second section. If there's a section below you want, move it up into the first section.

 

Note that this can only remove sections, it cannot reorder it. Changing the order of the "case" statements without moving them to a different section will have no effect on the section.

 

A profile case number should only be in the "to remove" section, or the "leave alone" section. The behavior of having it in both places is unknown (probably gets deleted, but I'm not sure). A profile case number that is not present in the list will be left alone. The name after the number (e.g. "// Stat bar") is only for human readers and does not affect the script. It is the number that comes before that which is important. In other words, changing "case 0: // Stat bar" to read "case 0: // Premium Features" will not remove premium features.

 

// ==UserScript==
// @name		   Sidebar Cleanup
// @namespace	  chrysalides
// @description	Clean up the sidebar
// @include		http://www.geocaching.com/my/
// ==/UserScript==

var allDivs, thisDiv;

allDivs = document.evaluate(
"//div[@class='ProfileWidget']",
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);

for (var i = 0; i < allDivs.snapshotLength; i++) {
thisDiv = allDivs.snapshotItem(i);

switch (i) {

// case statements here will have the corresponding element removed

case 0: // Stat bar
case 1: // Your GPS
case 5: // Geocaching with Twitter
	thisDiv.parentNode.removeChild(thisDiv);
	break;

// case statements here will leave the corresponding element untouched

case 2: // Search Options
case 3: // User Routes
case 4: // Field Notes
case 6: // Premium Features
case 7: // Account Options
case 8: // Google Earth
case 9: // Your Inventory
default:
	break;
}
}

Edited by Chrysalides
Link to comment
Nice scripts! I know how to create the script file itself, but where do I put the file? Can I just copy it over to the scripts folder or does it have to be installed through the GM interface? Thanks.

If you already have GreaseMonkey installed, follow these steps:

 

1. Go to your profile page http://www.geocaching.com/my

 

2. Right click on the monkey face at the bottom of the page. Choose "New User Script"

 

3. If this is the first time you're doing it, you might be asked to choose a text editor. Notepad works just fine. You'll need to hunt for it (on XP it is in c:\windows, not sure about Vista / Win7).

 

4. Fill in name (call it, say, customizeProfile), namespace (doesn't seem to matter - put in your name), description. For Includes, make sure the line http://www.geocaching.com/my is there. That is the web page that will trigger the script.

 

5. When Notepad opens up, cut and paste the text into it. I'd suggest copying the script body alone (don't copy the 6 lines on top of my script that begins with "//"). Use the ones that GreaseMonkey created for you instead.

 

I can host the script somewhere as well, but you should be careful about installing script from someone you don't know. If Lil Devil wants to vet and host the script, feel free to do so.

Link to comment

(left this since it might be useful for others)

 

The two code fragments I put above are complimentary and do different things. The longer one is for the widget. The one liner in the 1st post is the one that replaces "Visit Log" with "Log".

 

You can paste :

 

document.body.innerHTML= document.body.innerHTML.replace(/Visit Log/g,"Log");

 

at the end of the longer script if you want both actions.

Edited by Chrysalides
Link to comment

 

1. Go to your profile page http://www.geocaching.com/my

 

<snip>

 

 

It does not seem to work. My script is

// ==UserScript==
// @name		   gc_format
// @namespace	  jholly
// @description	Change format of personal profile page 
// @include		http://www.geocaching.com/my/default.aspx
// ==/UserScript==
document.body.innerHTML= document.body.innerHTML.replace(/Visit Log/g, "Log");

 

It is in ~\gm_scripts\gc_format. When I bring up the GM edit function the script is there and it shows as being installed. I still get

 

badlog.png

 

Perhaps I misunderstood.

 

Jim

Link to comment

 

1. Go to your profile page http://www.geocaching.com/my

 

<snip>

 

 

It does not seem to work. My script is

// ==UserScript==
// @name		   gc_format
// @namespace	  jholly
// @description	Change format of personal profile page 
// @include		http://www.geocaching.com/my/default.aspx
// ==/UserScript==
document.body.innerHTML= document.body.innerHTML.replace(/Visit Log/g, "Log");

 

It is in ~\gm_scripts\gc_format. When I bring up the GM edit function the script is there and it shows as being installed. I still get

 

badlog.png

 

Perhaps I misunderstood.

 

Jim

Hmm.. try this.

 

Right click on the monkey face, Manage User Scripts, click on the script to select it, on the right side where it says "Included pages", you probably see "http://www.geocaching.com/my/default.aspx". Click on that, choose edit, and change it to "http://www.geocaching.com/my/*"

 

I'd test it, but it appears the site is down right now. Hopefully making my script obsolete :lol:

 

Edit : tested, works for me. I think the difference might be the "default.aspx" at the end of your URL. Adding the "*" should take care of either. And sadly, my script is not obsolete yet.

 

I'd post a screen cap, but I don't have my usual utilities with me, and I don't want to struggle with Windows Paint.

Edited by Chrysalides
Link to comment

 

It does not seem to work. My script is

// ==UserScript==
// @name		   gc_format
// @namespace	  jholly
// @description	Change format of personal profile page 
// @include		http://www.geocaching.com/my/default.aspx
// ==/UserScript==
document.body.innerHTML= document.body.innerHTML.replace(/Visit Log/g, "Log");

 

You have added a space before "Log". Remove it and you should be OK.

 

// ==/UserScript==

document.body.innerHTML= document.body.innerHTML.replace(/Visit Log/g,"Log");

Link to comment

Many thanks to Chrysalides for getting me started on Greasemonkey scripts. I'm not a javascrip guru, but I can find my way around, and I've already made multiple changes that will make the pages more useful for me.

 

See? The new site changes weren't all bad. They annoyed me enough to help me learn something new!

Link to comment

I tried to set up the whitespace "fixer" as chrysalides has way up above. I must be doing something wrong as I cant get it to work. Is there anything I should be looking for to figure out why?

What part doesn't work? Does it change "Visit Log" into "Log"? If some other part is long (e.g. cache location name) it will still show up as 2 lines. Also did you try what was suggested in mtn-man's and my response to jholly a few posts above?

Link to comment

This will make it easier to install the script for those not willing to do the multiple step process above. It includes only the two changes of mine above. Please read the code before you install it. I've kept the code simple so that it should be fairly easy to follow. Only the XPath stuff is somewhat cryptic.

 

Link to script's page at userscripts.org

 

If you want to customize it, you'll still need to edit.

 

Edit : thanks to Lil Devil for suggesting the use of userscripts.org

Edited by Chrysalides
Link to comment
Oh, interesting. So if the site used 'Visit Log' as part of an element's id, this script would change that and hose things up?

Oops.. seems to have missed this. Thanks for the tips regarding CSS.

 

Yeah, the innerHTML replacement will replace anything in the HTML, not just the displayed text. The correct method would be to use the XPath stuff that I'm still struggling with. This article seems to be just what I'm looking for.

Link to comment
Perhaps Groundspeak can just give us the content of each page as XML and we can all become scripting experts and format them the way we want. Shouldn't be hard for cache pages, just deliver the GPX file. :lol:

I'm sure there's a GSAK macro for that :P

 

(I haven't found anything in GSAK that's comparable in speed and usability to the Google Map view on geocaching.com though... anyone knows of one? HTML Google Maps Nearest v0.8 is nowhere near as snappy)

Link to comment
Oh, interesting. So if the site used 'Visit Log' as part of an element's id, this script would change that and hose things up?

Oops.. seems to have missed this. Thanks for the tips regarding CSS.

 

Yeah, the innerHTML replacement will replace anything in the HTML, not just the displayed text. The correct method would be to use the XPath stuff that I'm still struggling with. This article seems to be just what I'm looking for.

 

Did you ever get this figured out?

Link to comment

I tried to set up the whitespace "fixer" as chrysalides has way up above. I must be doing something wrong as I cant get it to work. Is there anything I should be looking for to figure out why?

What part doesn't work? Does it change "Visit Log" into "Log"? If some other part is long (e.g. cache location name) it will still show up as 2 lines. Also did you try what was suggested in mtn-man's and my response to jholly a few posts above?

 

Between the suggestion to use * and removing that pesky extra "white" space before Log its all better now. Thanks.

Link to comment
Did you ever get this figured out?

Thanks for the prod :lol:

 

The one line innerHTML replace is now:

 

textNodes = document.evaluate("//text()",
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);

for (var i=0;i<textNodes.snapshotLength;i++) {
var node = textNodes.snapshotItem(i);
node.data = node.data.replace(/Visit Log/g,"Log");
}

 

If you want to replace anything else, just replicate the node.data = node.data.replace(...) line.

 

I'll update the script on userscripts shortly. Need to run out for a moment (no, it's not for a FTF).

 

Edit : updated. http://userscripts.org/scripts/show/66400

Edited by Chrysalides
Link to comment
Perhaps Groundspeak can just give us the content of each page as XML and we can all become scripting experts and format them the way we want. Shouldn't be hard for cache pages, just deliver the GPX file. :lol:

I'm sure there's a GSAK macro for that :P

 

(I haven't found anything in GSAK that's comparable in speed and usability to the Google Map view on geocaching.com though... anyone knows of one? HTML Google Maps Nearest v0.8 is nowhere near as snappy)

 

Export from gsak to Google Earth. WAY snappier than any HTML based map, and you can do many more caches.

 

I prefer to run the gpx export through GoogleEarthTweaker (google it :D first, so that i get the small icons, though.

Link to comment
Did you ever get this figured out?

Thanks for the prod :lol:

 

The one line innerHTML replace is now:

 

textNodes = document.evaluate("//text()",
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);

for (var i=0;i<textNodes.snapshotLength;i++) {
var node = textNodes.snapshotItem(i);
node.data = node.data.replace(/Visit Log/g,"Log");
}

 

If you want to replace anything else, just replicate the node.data = node.data.replace(...) line.

 

I'll update the script on userscripts shortly. Need to run out for a moment (no, it's not for a FTF).

 

Edit : updated. http://userscripts.org/scripts/show/66400

 

Thanks!

Link to comment
Export from gsak to Google Earth. WAY snappier than any HTML based map, and you can do many more caches.

 

I prefer to run the gpx export through GoogleEarthTweaker (google it :lol: first, so that i get the small icons, though.

Thanks for the tip - I didn't want to use another program, but if it works better... I'll give it a try.

 

By the way, in case anyone is interested, I figured out why Prime Suspect's Quick Hints is not working. Look for all the "getElementById" - the element ID has changed. "Encrypt" is now "ctl00_ContentBody_Encrypt" and "Hints" is now "ctl00_ContentBody_Hints". Change the text and quick hints is now quick again.

Link to comment

Added this with Stylish to contract some of the white space on the sidebar widgits on the My Profile page:

@namespace url(http://www.w3.org/1999/xhtml);

@-moz-document url-prefix("http://www.geocaching.com/my/") {
.WidgetBody { line-height: 110% ! important; }
}

 

And this one to clean up the My Friends page:

@namespace url(http://www.w3.org/1999/xhtml);

@-moz-document url("http://www.geocaching.com/my/myfriends.aspx") {
.FriendWidget { line-height: 110% ! important; }
.FriendList { border-top:1px solid #a3a3a3; }
}

 

I wasn't happy with what my first change did to individual cache pages and changed it to:

@namespace url(http://www.w3.org/1999/xhtml);

@-moz-document url-prefix(http://www.geocaching.com/seek/nearest) {
table.Table {line-height: 100% ! important }
}

@-moz-document url-prefix(http://www.geocaching.com/my) {
table.Table {line-height: 100% ! important }
}

 

so that it doesn't affect individual cache listings. Still collapses the log text on http://www.geocaching.com/my/geocaches.aspx but I don't look at that page very much so I wasn't too worried about it. :P

 

This one will darken the color of alternating rows: The default doesn't really bother me, but I was on a roll and figured why stop now?

@namespace url(http://www.w3.org/1999/xhtml);

@-moz-document domain("geocaching.com") {
table.Table tr.AlternatingRow td,.AlternatingRow,table.Table tr td.AlternatingRow,tr.Row1 td,tr.Row3 td,tr.Row5 td,tr.Row7 td,tr.Row9 td{
background-color:#dde1e8 ! important;
}

You can play around with the color on that one, add border lines if you want, etc. For example #eff4f9 is the BG color used for the coordinate box at the top of every cache page - that is a very slight change from the color used currently for alternating rows: #edf1f8. This doesn't work for search results as they define the background color on the table tags. e.g. <tr bgcolor='#FFFFFF'... Bleh.

 

Tried uploading these to userstyles.org, but it's throwing errors on upload for me.

 

To install any of these with Stylish:

Right Click on the S -> Write new style -> Blank style

Give it a name and copy in the code.

 

If you like you could probably make one new style and you'd just need the @namespace url(http://www.w3.org/1999/xhtml); line once.

Edited by rob3k
Link to comment
Export from gsak to Google Earth. WAY snappier than any HTML based map, and you can do many more caches.

 

I prefer to run the gpx export through GoogleEarthTweaker (google it :P first, so that i get the small icons, though.

Thanks for the tip - I didn't want to use another program, but if it works better... I'll give it a try.

 

By the way, in case anyone is interested, I figured out why Prime Suspect's Quick Hints is not working. Look for all the "getElementById" - the element ID has changed. "Encrypt" is now "ctl00_ContentBody_Encrypt" and "Hints" is now "ctl00_ContentBody_Hints". Change the text and quick hints is now quick again.

 

Wow, thanks again! Used that tip to fix the Log Find Counter script, the change isn't exactly the same, but it's the same basic idea.

 

These lines need to be changed - current version commented out:

 

//updated - rob3k

//var e_LogIn = document.getElementById("Header_LoginUrl");

var e_LogIn = document.getElementById("ctl00_LoginUrl");

 

// updated - rob3k

//e_TxtArea = document.getElementById("LogBookPanel1_tbLogInfo");

e_TxtArea = document.getElementById("ctl00_ContentBody_LogBookPanel1_tbLogInfo");

 

//updated - rob3k

//e_ddLogType = document.getElementById('LogBookPanel1_ddLogType');

e_ddLogType = document.getElementById('ctl00_ContentBody_LogBookPanel1_ddLogType');

Edited by rob3k
Link to comment
(left this since it might be useful for others)

The two code fragments I put above are complimentary and do different things. The longer one is for the widget. The one liner in the 1st post is the one that replaces "Visit Log" with "Log".

 

You can paste :

document.body.innerHTML= document.body.innerHTML.replace(/Visit Log/g,"Log");

at the end of the longer script if you want both actions.

 

I haven't read the entire thread yet, so this may have already been mentioned, but to change Visit Log to simply Log on all pages, add an asterisc to the "include" path (http://www.geocaching.com/my/*)

Link to comment

Is this turning into a GreaseMonkey script to reset the entire website back to what it was before the upgrade? :)

:P

 

Actually, I think the only thing I really have a problem with is the excessive vertical white space. There are other little things, but if it wasn't for Visit Log wrapping to two lines on my profile page I probably wouldn't have cared enough to figure out work arounds.

Edited by rob3k
Link to comment
We have to, it is the only way to get the song by palmetto out of our heads. Jim
Guess what was going through my head as I opened this thread. Aarrgghhhh!! :P

I'm afraid to ask... what song? I saw something about "scrollin'" but don't know what music is supposed to go with it.

 

Is ignorance bliss?

 

As for the other script, I'm not sure if I want to single out He Whose Avatar Is Shirtless on that site :) I must admit, though, that I feel a lot less provoked by his posts after replacing the avatar image. Very strange. And now with the knowledge gained from this current exercise, we can replace signature lines as well :)

Link to comment
We have to, it is the only way to get the song by palmetto out of our heads. Jim
Guess what was going through my head as I opened this thread. Aarrgghhhh!! :)

I'm afraid to ask... what song? I saw something about "scrollin'" but don't know what music is supposed to go with it.

 

Is ignorance bliss?

 

As for the other script, I'm not sure if I want to single out He Whose Avatar Is Shirtless on that site :P I must admit, though, that I feel a lot less provoked by his posts after replacing the avatar image. Very strange. And now with the knowledge gained from this current exercise, we can replace signature lines as well :)

 

Or change login names... :P

 

I use adblock to nix any weird avatar or sig images on forums. One guy had some really creepy image of a dog wearing glasses.

Edited by rob3k
Link to comment
I use adblock to nix any weird avatar or sig images on forums. One guy had some really creepy image of a dog wearing glasses.
Yes, but can you use adblock to remove the dog's glasses, or to change them into sunglasses? Chrysalides' script can change a drooling dragon into a cute little mouse, or put a shirt on a shirtless avatar.

 

By the way, who's avatar were you referring to?

Link to comment
Guest
This topic is now closed to further replies.
Followers 4
×
×
  • Create New...