// ==UserScript== // @name Geocaching Druckausgabe // @namespace http://www.geocaching.com/ // @version 0.2 // @description try to take over the world! // @author You // @match https://www.geocaching.com/seek/cdpf.aspx?guid=* // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; window.getCity = function(sCoords) { var aCoords; sCoords = sCoords.split('°').join(''); sCoords = sCoords.split('.').join(' '); aCoords = sCoords.split(' '); var lat = Number(aCoords[1]) + Number(aCoords[2]) / 60 + Number(aCoords[3]) / 60000; if (aCoords[0] == 'S') { lat = 0 - lat; } var lon = Number(aCoords[5]) + Number(aCoords[6]) / 60 + Number(aCoords[7]) / 60000; if (aCoords[4] == 'W') { lon = 0 - lon; } var geocoder = new google.maps.Geocoder(); geocoder.geocode({'location': {lat: lat, lng: lon}}, function(results, status) { if (status === google.maps.GeocoderStatus.OK) { for(var i = 0; i < results.length; i++) { if (results[i].formatted_address.split(',').length == 2) { document.querySelector('.gc-city').textContent = results[i].formatted_address; break; } } } }); }; window.initMap = function() { var oCacheData = {}; var elements = document.querySelectorAll('#Content .ui-widget-content'); var waypoints = []; var i; var waypoint; oCacheData.name = document.querySelector('#Content h2 ').textContent.trim(); oCacheData.coords = document.querySelector('.LatLong ').textContent.trim(); oCacheData.lat = oCacheData.coords.split(' ')[0]; oCacheData.lon = oCacheData.coords.split(' ')[3]; oCacheData.code = document.querySelector('#Header .HalfRight h1').textContent.trim(); oCacheData.type = document.querySelector('#Content h2 img').getAttribute('alt'); oCacheData.difficulty = document.querySelectorAll('#Content .DiffTerr img')[0].getAttribute('alt').split('out of 5')[0].trim(); oCacheData.terrain = document.querySelectorAll('#Content .DiffTerr img')[1].getAttribute('alt').split('out of 5')[0].trim(); oCacheData.size = document.querySelector('#Content .Third.AlignCenter small').textContent.replace('(', '').replace(')', '').trim(); elements = document.querySelectorAll('#Waypoints tbody tr'); for (i = 0; i < elements.length; i++) { if (elements[i].getAttribute('ishidden')) { if (waypoint !== undefined && waypoint !== null) { waypoints.push(waypoint); waypoint = null; } waypoint = {}; waypoint.id = elements[i].querySelectorAll('td')[4].textContent.trim(); waypoint.coords = elements[i].querySelectorAll('td')[6].textContent.replace('???', oCacheData.lat + ' ____________ ' + oCacheData.lon + ' ____________ ').replace('?', '__').trim(); waypoint.type = elements[i].querySelector('td:nth-child(6) a').textContent.trim(); } else { waypoint.content = elements[i].innerText.replace('Note:', '').trim(); } } if (waypoint !== undefined && waypoint !== null) { waypoints.push(waypoint); } console.dir(waypoints); elements = document.querySelectorAll('#Content .ui-widget-content'); elements[3].remove(); elements[4].remove(); elements[5].remove(); elements[6].remove(); elements[7].remove(); elements[8].remove(); elements[0].remove(); elements[1].remove(); document.querySelector('#Footer').remove(); document.querySelector('#Header').remove(); document.querySelector('.TermsWidget').remove(); document.querySelector('p.Meta').remove(); document.querySelector('p.Meta').remove(); document.querySelector('p.Meta').remove(); document.querySelector('p.Meta').remove(); document.querySelector('p.Meta').remove(); document.querySelector('p.Meta').remove(); document.querySelector('p.Meta').remove(); document.querySelector('p.Meta').remove(); document.querySelector('.Third').remove(); document.querySelector('.Third').remove(); document.querySelector('#Content h2').remove(); document.querySelector('#Content h2').remove(); document.querySelector('#Content > p').remove(); var newElements = document.createElement('section'); newElements.className = 'gc'; newElements.innerHTML = '
' + waypoints[i].content + '
'; } if (content !== '') { content = '