\
';
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 ($('ul.profile-panel-menu').length) { // Special case for https://www.geocaching.com/account/settings/preferences
$('ul.profile-panel-menu').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 + '
');
}
$('#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;
// Since everything in the logbook is ajax, we need to wait for the elements
waitForKeyElements('#cache_logs_table tr', Logbook);
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,
cacheOwner = result.data.owner,
challengeCheckerTagIds = result.data.challengeCheckerTagIds,
geocacheLogsPerCountry = result.data.geocacheLogsPerCountry,
location = [],
fp = 0,
fpp = 0,
fpw = 0,
elevation = '',
html = '';
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') && geocacheLogsPerCountry.length > 0) {
$('#ctl00_ContentBody_lblFindCounts').append('
Found logs per country according to Project-GC.com
');
for (var i = 0; i < geocacheLogsPerCountry.length; i++) {
$('#geocacheLogsPerCountry ul').append('
' + geocacheLogsPerCountry[i].cnt + '
');
}
$('#geocacheLogsPerCountry ul').after('' + geocacheLogsPerCountry.length + ' unique countries');
}
}
}
});
}
// 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();
}
// 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', '39px');
$('#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.
').insertBefore('#divContentMain div.DownloadLinks');
$('#divContentMain div.DownloadLinks, #DownloadLinksToggle .arrow.open').hide();
}
// Resolve the coordinates into an address
if (IsSettingEnabled('addAddress')) {
coordinates = $('#ctl00_ContentBody_MapLinks_MapLinks li a').attr('href'),
latitude = coordinates.replace(/.*lat=([^&]*)&lng=.*/, "$1"),
longitude = coordinates.replace(/.*&lng=(.*)$/, "$1"),
url = 'http://maps.googleapis.com/maps/api/geocode/json?latlng=' + latitude + ',' + longitude + '&sensor=false';
GM_xmlhttpRequest({
method: "GET",
url: url,
onload: function(response) {
var result = JSON.parse(response.responseText);
if (result.status !== 'OK') {
return false;
}
var formattedAddress = result.results[0].formatted_address;
$('#ctl00_ContentBody_LocationSubPanel').append(formattedAddress + ' ');
}
});
}
// Add number of finds per type to the top
if (IsSettingEnabled('cloneLogsPerType') && typeof $('#ctl00_ContentBody_lblFindCounts').html() !== 'undefined') {
$('#ctl00_ContentBody_CacheInformationTable').before('
');
}
// 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 = 'http://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 = 'http://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 = 'http://project-gc.com/ProfileStats/' + encodeURIComponent(owner);
$(this).children(':nth-child(3)').append(' ');
});
}
// Decrypt the hint
if (IsSettingEnabled('decryptHints')) {
unsafeWindow.dht();
}
// 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();
});
}
});
}
}
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('p.logOwnerProfileName strong a');
var profileName = profileNameElm.html();
if (typeof profileName !== 'undefined') {
profileName = profileNameElm.append('')
.append('');
}
}
if(IsSettingEnabled('parseExifLocation')) {
$(jNode).find('table.LogImagesTable tr>td').each(function() {
var url = $(this).find('a.tb_images').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).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());
}
});
});
});
}
// Save to latest logs
if (latestLogs.length < 5) {
var node = $(jNode).find('div.HalfLeft.LogType strong img[src]'),
logType = {};
if (node.length === 0)
return false;
logType = {
'src': node.attr('src'),
'alt': node.attr('alt'),
'title': node.attr('title')
};
logType.id = +logType.src.replace(/.*logtypes\/(\d+)\.png/, "$1");
// First entry is undefined, due to ajax
if (logType.src) {
latestLogs.push('');
// 2 = found, 3 = dnf, 4 = note, 5 = archive, 22 = disable, 24 = publish, 45 = nm, 46 = owner maintenance, 68 = reviewer note
if ($.inArray(logType.id, [3, 5, 22, 45, 68]) !== -1) {
latestLogsAlert = true;
}
}
// Show latest logs
// Enhanced Nov 2016 to show icons for up to 5 of the latest logs
if (IsSettingEnabled('addLatestLogs') && latestLogs.length <= 5) {
var images = latestLogs.join('');
$('#latestLogIcons').remove();
$('#ctl00_ContentBody_size p').removeClass('AlignCenter').addClass('NoBottomSpacing');
if (latestLogsAlert) {
$('#ctl00_ContentBody_size').append('