\
';
if ($('#ctl00_uxLoginStatus_divSignedIn ul.logged-in-user').length) { // The default look of the header bar
$('#ctl00_uxLoginStatus_divSignedIn ul.logged-in-user').prepend('
' + html + '
');
} else if ($('ul.profile-panel li.li-user').length) { // new style, e.g. https://www.geocaching.com/play/search
$('ul.profile-panel').prepend('
' + html + '
');
} else if ($('#uxLoginStatus_divSignedIn ul.logged-in-user').length) { // Special case for https://www.geocaching.com/map/
$('#uxLoginStatus_divSignedIn ul.logged-in-user').prepend('
' + html + '
');
}
$("#pgcUserMenuButton, #pgcSettingsOverlay").click(function(e) {
$('#pgcUserMenu, #pgcSettingsOverlay').toggle();
})
$('#pgcUserMenuSave').click(function(e) {
SaveSettings(e);
});
}
/**
* getGcCodeFromPage
* @return string
*/
function getGcCodeFromPage() {
return $('#ctl00_ContentBody_CoordInfoLinkControl1_uxCoordInfoCode').html();
}
/**
* addToVGPS
*/
function addToVGPS(gccode) {
var listId = $('#comboVGPS').val(),
url = null;
if (typeof(gccode) === 'undefined') { // The map provides the gccode itself
gccode = getGcCodeFromPage();
}
url = pgcApiUrl + 'AddToVGPSList?listId=' + listId + '&gccode=' + gccode + '§ionName=GM-script';
GM.xmlHttpRequest({
method: "GET",
url: url,
onload: function(response) {
var result = JSON.parse(response.responseText),
msg = (result.status === 'OK') ? 'Geocache added to Virtual-GPS!' : 'Geocache not added to Virtual-GPS :(';
$('#btnAddToVGPS').css('display', 'none');
$('#btnRemoveFromVGPS').css('display', '');
alert(msg);
return true;
},
onerror: function(response) {
console.log(response);
return false;
}
});
return true;
}
/**
* removeFromVGPS
*/
function removeFromVGPS(gccode) {
var listId = $('#comboVGPS').val(),
url = null;
if (typeof(gccode) === 'undefined') { // The map provides the gccode itself
gccode = getGcCodeFromPage();
}
url = pgcApiUrl + 'RemoveFromVGPSList?listId=' + listId + '&gccode=' + gccode;
GM.xmlHttpRequest({
method: "GET",
url: url,
onload: function(response) {
var result = JSON.parse(response.responseText),
msg = (result.status === 'OK') ? 'Geocache removed from Virtual-GPS!' : 'Geocache not removed from Virtual-GPS :(';
$('#btnAddToVGPS').css('display', '');
$('#btnRemoveFromVGPS').css('display', 'none');
alert(msg);
return true;
},
onerror: function(response) {
console.log(response);
return false;
}
});
}
function Page_Profile() {
// Override gc.com function on alerting for external links to not alert for Project-GC URLs
var gcAlertOverride = document.createElement('script');
gcAlertOverride.type = "text/javascript";
gcAlertOverride.innerHTML = `(function() {
var _old_isGeocachingDomain = isGeocachingDomain;
isGeocachingDomain = function(url) {
return (_old_isGeocachingDomain.apply(this, arguments)
|| url == "project-gc.com"
|| url == "www.project-gc.com");
};
})();`;
document.getElementsByTagName('head')[0].appendChild(gcAlertOverride);
}
/**
* Page_CachePage
*/
function Page_CachePage() {
var gccode = getGcCodeFromPage(),
placedBy = $('#ctl00_ContentBody_mcd1 a').html(),
lastUpdated = $('#ctl00_ContentBody_bottomSection p small time').get(1),
lastFound = $('#ctl00_ContentBody_bottomSection p small time').get(2),
coordinates, latitude, longitude, url;
lastUpdated = (lastUpdated) ? lastUpdated.dateTime : false;
lastFound = (lastFound) ? lastFound.dateTime : false;
if (subscription) {
// Get geocache data from Project-GC
url = pgcApiUrl + 'GetCacheDataFromGccode&gccode=' + gccode;
if (lastUpdated)
url += '&lastUpdated=' + lastUpdated;
if (lastFound)
url += '&lastFound=' + lastFound;
GM.xmlHttpRequest({
method: "GET",
url: url,
onload: function(response) {
var result = JSON.parse(response.responseText),
cacheData = result.data.cacheData,
bearing = result.data.bearing,
cacheOwner = result.data.owner,
challengeCheckerTagIds = result.data.challengeCheckerTagIds,
geocacheLogsPerCountry = result.data.geocacheLogsPerCountry,
myNumberOfLogs = result.data.myNumberOfLogs,
location = [],
fp = 0,
fpp = 0,
fpw = 0,
elevation = '',
html = '';
challengeCheckerResults = result.data.challengeCheckerResults;
// Add an alert in top if there are Found it-logs which doesn't seem to fulfill the requirements
if(challengeCheckerResults !== false) {
var suspiciousFoundItLogs = [];
for(var logId in challengeCheckerResults) {
if(typeof challengeCheckerResults[logId] !== 'undefined' && challengeCheckerResults[logId]['status'] == 'fail') {
suspiciousFoundItLogs.push(logId);
}
}
if(suspiciousFoundItLogs.length != 0) {
var suspiciousFoundItLog = '
Cache Issues:
\
\
The following Found it logs might not fulfill the requirements: ';
for(var i = 0 ; i < suspiciousFoundItLogs.length ; i++) {
suspiciousFoundItLog = suspiciousFoundItLog + ' ' + challengeCheckerResults[suspiciousFoundItLogs[i]]['profileName'] + ' ';
}
suspiciousFoundItLog = suspiciousFoundItLog + 'Please understand that the checker result is a cached result. Also the geocacher might very well have fulfilled it in the past, external factors might have changed.
';
$('div.span-6.right.last').last().next().after(suspiciousFoundItLog);
}
}
//--
if (result.status == 'OK' && typeof cacheData !== 'undefined') {
// If placed by != owner, show the real owner as well.
if (placedBy !== cacheOwner) {
$('#ctl00_ContentBody_mcd1 span.message__owner').before(' (' + cacheOwner + ')');
}
// Append link to Profile Stats for the cache owner
// Need to real cache owner name from PGC since the web only has placed by
if (IsSettingEnabled('profileStatsLinks')) {
$('#ctl00_ContentBody_mcd1 span.message__owner').before('');
}
// Add FP/FP%/FPW below the current FP
if (IsSettingEnabled('addPgcFp')) {
fp = parseInt(+cacheData.favorite_points, 10),
fpp = parseInt(+cacheData.favorite_points_pct, 10),
fpw = parseInt(+cacheData.favorite_points_wilson, 10);
$('#uxFavContainerLink').append('
';
for (var i = 0; i < challengeCheckerTagIds.length; i++) {
html += '';
}
html += '
';
$('#ctl00_ContentBody_detailWidget').before(html);
}
// Display warning message if cache is logged and no longer be logged
if (cacheData.locked) {
$('ul.OldWarning').append('
This cache has been locked and can no longer be logged.
');
}
// Add geocache logs per profile country table
if (IsSettingEnabled('addGeocacheLogsPerProfileCountry')) {
html = '
';
html += '' + geocacheLogsPerCountry['willAttend'].length + ' unique countries';
html += 'Event statistics';
}
if(typeof(geocacheLogsPerCountry['found']) != 'undefined' && geocacheLogsPerCountry['found'].length > 0) {
html += '
Found logs per country according to Project-GC.com
';
html += '
';
for (var i = 0; i < geocacheLogsPerCountry['found'].length; i++) {
html += '
' + geocacheLogsPerCountry['found'][i].cnt + '
';
}
html += '
';
html += '' + geocacheLogsPerCountry['found'].length + ' unique countries';
}
html += '
';
$('#ctl00_ContentBody_lblFindCounts').append(html);
}
// Add my number of logs above the log button
if (IsSettingEnabled('addMyNumberOfLogs')) {
$('
You have ' + myNumberOfLogs + ' logs according to Project-GC
').insertBefore('#ctl00_ContentBody_GeoNav_logButton');
}
// Append the same number to the added logbook link
if (IsSettingEnabled('logbookLinks')) {
$('#pgc-logbook-yours').html('Yours (' + myNumberOfLogs + ')')
}
}
// Since everything in the logbook is ajax, we need to wait for the elements
// We also want to wait on challengeCheckerResults
waitForKeyElements('#cache_logs_table tbody tr', Logbook);
}
});
}
// Add weekday of place date
if (IsSettingEnabled('showWeekday')) {
var match = $('meta[name="description"]')[1].content.match(/([0-9]{2})\/([0-9]{2})\/([0-9]{4})/);
if (match) {
var date = new Date(match[3], match[1]-1, match[2]);
var weekday = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
var text = $($('#ctl00_ContentBody_mcd2')[0].childNodes[0]).text();
var pos = text.indexOf(':') + 2;
var newText = text.substring(0, pos);
newText += weekday[date.getDay()] + ', ';
newText += text.substring(pos, text.length);
var newNode = document.createTextNode(newText);
$('#ctl00_ContentBody_mcd2')[0].replaceChild(newNode, $('#ctl00_ContentBody_mcd2')[0].childNodes[0]);
}
}
// Tidy the web
if (IsSettingEnabled('tidy')) {
$('#ctl00_divContentMain p.Clear').css('margin', '0');
$('div.Note.PersonalCacheNote').css('margin', '0');
$('h3.CacheDescriptionHeader').remove();
$('#ctl00_ContentBody_EncryptionKey').remove();
$('#ctl00_ContentBody_GeoNav_foundStatus').css('margin-bottom', '0');
}
// Make it easier to copy the gccode
if (IsSettingEnabled('makeCopyFriendly')) {
$('#ctl00_ContentBody_CoordInfoLinkControl1_uxCoordInfoLinkPanel').
html('
' + gccode + '
' +
'
');
$('#ctl00_ContentBody_CoordInfoLinkControl1_uxCoordInfoLinkPanel').css('font-weight', 'inherit').css('margin-right', '27px');
$('#ctl00_ContentBody_CoordInfoLinkControl1_uxCoordInfoLinkPanel div').css('margin', '0 0 5px 0');
$('#ctl00_ContentBody_CoordInfoLinkControl1_uxCoordInfoLinkPanel div p').css('font-weight', 'bold');
}
// Add PGC Map links
if (IsSettingEnabled('addPgcMapLinks')) {
coordinates = $('#ctl00_ContentBody_MapLinks_MapLinks li a').attr('href'),
latitude = coordinates.replace(/.*lat=([^&]*)&lng=.*/, "$1"),
longitude = coordinates.replace(/.*&lng=(.*)$/, "$1");
// var mapUrl = pgcUrl + 'Maps/mapcompare/?profile_name=' + gccomUsername +
// '&nonefound=on&ownfound=on&location=' + latitude + ',' + longitude +
// '&max_distance=5&submit=Filter';
var mapUrl = pgcUrl + 'LiveMap/#c=' + latitude + ',' + longitude + ';z=14';
// $('#ctl00_ContentBody_CoordInfoLinkControl1_uxCoordInfoLinkPanel').append(
// '
'
);
}
// Remove the UTM coordinates
// $('#ctl00_ContentBody_CacheInformationTable div.LocationData div.span-9 p.NoBottomSpacing br').remove();
if (IsSettingEnabled('removeUTM')) {
$('#ctl00_ContentBody_LocationSubPanel').html('');
// And move the "N 248.3 km from your home location"
$('#ctl00_ContentBody_LocationSubPanel').after($('#lblDistFromHome'));
}
// Remove ads
// PGC can't really do this officially
// $('#ctl00_ContentBody_uxBanManWidget').remove();
// Remove disclaimer
if (IsSettingEnabled('removeDisclaimer')) {
$('#divContentMain div.span-17 div.Note.Disclaimer').remove();
}
// If the first log is a DNF, display a blue warning on top of the page
if($('#cache_logs_table tr:first td div.LogDisplayRight strong img').attr('src') === '/images/logtypes/3.png') {
var htmlFirstLogDnf = '
Cache Issues:
\
\
The latest log for this cache is a DNF, please read the log before your own search.
');
}
// Add link to PGC gallery
if (subscription && IsSettingEnabled('addPgcGalleryLinks')) {
var html = ' ';
$('.CacheDetailNavigation ul li:first').append(html);
}
// Add map links for each bookmarklist
if (IsSettingEnabled('addMapBookmarkListLinks')) {
$('ul.BookmarkList li').each(function() {
var guid = $(this).children(':nth-child(1)').attr('href').replace(/.*\?guid=(.*)/, "$1");
var owner = $(this).children(':nth-child(3)').text();
// Add the map link
url = 'https://project-gc.com/Tools/MapBookmarklist?owner_name=' + encodeURIComponent(owner) + '&guid=' + encodeURIComponent(guid);
$(this).children(':nth-child(1)').append(' ');
// Add gallery link for the bookmark list
url = 'https://project-gc.com/Tools/Gallery?bml_owner=' + encodeURIComponent(owner) + '&bml_guid=' + encodeURIComponent(guid) + '&submit=Filter';
$(this).children(':nth-child(1)').append(' ');
// Add profile stats link to the owner
url = 'https://project-gc.com/ProfileStats/' + encodeURIComponent(owner);
$(this).children(':nth-child(3)').append(' ');
});
}
// Decrypt the hint
if (IsSettingEnabled('decryptHints') && $('#ctl00_ContentBody_lnkDH')[0].title == 'Decrypt') {
$('#ctl00_ContentBody_lnkDH')[0].click();
}
// VGPS form
if (IsSettingEnabled('showVGPS')) {
GM.xmlHttpRequest({
method: "GET",
url: pgcApiUrl + 'GetExistingVGPSLists?gccode=' + gccode,
onload: function(response) {
var result = JSON.parse(response.responseText),
vgpsLists = result.data.lists,
selected = result.data.selected,
existsIn = result.data.existsIn,
selectedContent,
existsContent,
html = '
Add to VGPS ',
listId;
html += '';
if (existsIn.indexOf(String(selected)) == -1) {
html += ' ';
html += ' ';
} else {
html += ' ';
html += ' ';
}
html += '
';
$('div.CacheDetailNavigation ul:first').append(html);
$('#comboVGPS').change(function() {
selected = $(this).find(':selected').val();
if (existsIn.indexOf(String(selected)) == -1) {
$('#btnAddToVGPS').css('display', '');
$('#btnRemoveFromVGPS').css('display', 'none');
} else {
$('#btnAddToVGPS').css('display', 'none');
$('#btnRemoveFromVGPS').css('display', '');
}
});
$('#btnAddToVGPS').click(function(event) {
event.preventDefault();
addToVGPS();
});
$('#btnRemoveFromVGPS').click(function(event) {
event.preventDefault();
removeFromVGPS();
});
}
});
}
// Change font in personal cache note to monospaced
if (IsSettingEnabled('cachenoteFont')) {
$("#viewCacheNote,#cacheNoteText").css("font-family", "monospace").css("font-size", "12px");
$("#viewCacheNote").on("DOMSubtreeModified", function() {
$(".inplace_field").css("font-family", "monospace").css("font-size", "12px");
});
}
if (IsSettingEnabled('logbookLinks')) {
$('\
| Yours\
| Friends\'\
').insertAfter( $('#ctl00_ContentBody_uxLogbookLink') );
}
}
function Page_Logbook() {
// Since everything in the logbook is ajax, we need to wait for the elements
waitForKeyElements('#AllLogs tr', Logbook);
waitForKeyElements('#PersonalLogs tr', Logbook);
waitForKeyElements('#FriendLogs tr', Logbook);
}
function Logbook(jNode) {
// Add Profile stats and gallery links after each user
if (IsSettingEnabled('profileStatsLinks')) {
var profileNameElm = $(jNode).find('a.h5');
var profileName = profileNameElm.html();
if (typeof profileName !== 'undefined') {
profileName = profileNameElm.append('')
.append('');
}
}
if(IsSettingEnabled('parseExifLocation')) {
$(jNode).find('ul.LogImagesTable li>a').each(function() {
var url = $(this).attr('href');
var thumbnailUrl = url.replace('/img.geocaching.com/cache/log/large/', '/img.geocaching.com/cache/log/thumb/');
var imgElm = $(this).find('img');
$(imgElm).attr('src', thumbnailUrl);
$(imgElm).removeAttr('width');
$(imgElm).removeAttr('height');
$(imgElm).next().css('vertical-align', 'top');
$(imgElm).load(function() {
EXIF.getData($(imgElm)[0], function() {
// console.log(EXIF.pretty(this));
var coords = GetCoordinatesFromExif(this);
if(coords != false) {
$('EXIF Location: ' + coords + '').insertAfter($(imgElm).parent());
}
});
});
});
}
if(IsSettingEnabled('addCachedChallengeCheckerResults') && typeof(challengeCheckerResults) !== 'undefined' && challengeCheckerResults !== null) {
var classes = $(jNode).attr('class');
var logId = classes.match(/l-[0-9]+/)[0].replace('l-', '');
if(typeof(challengeCheckerResults[logId]) !== 'undefined') {
if(challengeCheckerResults[logId]['status'] == 'success') {
$(jNode).find('div.LogDisplayLeft').first().append('
Checker result ' + challengeCheckerResults[logId]['lastRun'] + ' UTC: