// ==UserScript== // @name Send to c:geo // @namespace http://send2.cgeo.org/ // @description Add button "Send to c:geo" to geocaching.com and opencaching.de // @author c:geo team and contributors // @require http://code.jquery.com/jquery-3.5.1.min.js // @include /^https?://www\.geocaching\.com/play/(search|map|owner)/ // @include /^https?://www\.geocaching\.com/play/owner/(published|unpublished|archived)/ // @include /^https?://www\.geocaching\.com/play/owner/(published|unpublished|archived)/events/ // @include /^https?://www\.geocaching\.com/seek/(cache_details\.|nearest\.|)/ // @include /^https?://www\.geocaching\.com/my/(recentlyviewedcaches|default)\./ // @include /^https?://www\.geocaching\.com/(map/|geocache/)/ // @include /^https?://www\.geocaching\.com/plan/lists/ // @include /^https?://www\.geocaching\.com/account/dashboard/ // @include /^https?://www\.opencaching\.de/(viewcache|myhome|map2).php/ // @icon https://www.cgeo.org/send2cgeo.png // @downloadURL https://github.com/cgeo/send2cgeo/raw/release/send2cgeo.user.js // @updateURL https://github.com/cgeo/send2cgeo/raw/release/send2cgeo.user.js // @supportURL https://github.com/cgeo/send2cgeo/issues // @version 2022.09.14 // @grant GM_setValue // @grant GM_getValue // ==/UserScript== 'use strict'; // Function that handles the actual sending // The window.s2geo() functions have to be insert into the pagehead, so that they be called with onclick="window.s2geo" var s2cgScript = document.createElement('script'); s2cgScript.type = 'text/javascript'; s2cgScript.innerHTML = 'window.s2geo = function(GCCode) {' + " var sendCache = window.open('https://send2.cgeo.org/add.html?cache=' + GCCode, 'send' + GCCode, 'width=200,height=100,top=10,left=10,menubar=no,status=no');" + ' window.setTimeout(' + ' function() {' + ' sendCache.close();' + ' },' + ' 3000' + ' )' + '};'; document.getElementsByTagName('head')[0].appendChild(s2cgScript); // This solves the problems with jquery var quitOnAdFrames = function() { var quitOnAdFramesDeref = new jQuery.Deferred(); if (window.name) { if (window.name.substring(0, 18) !== 'google_ads_iframe_') { quitOnAdFramesDeref.resolve(); } else { quitOnAdFramesDeref.reject(); } } else { quitOnAdFramesDeref.resolve(); } return quitOnAdFramesDeref.promise(); }; var jqueryInit = function(c) { if (typeof c.$ === "undefined") { c.$ = c.$ || unsafeWindow.$ || window.$ || null; } if (typeof c.jQuery === "undefined") { c.jQuery = c.jQuery || unsafeWindow.jQuery || window.jQuery || null; } var jqueryInitDeref = new jQuery.Deferred(); jqueryInitDeref.resolve(); return jqueryInitDeref.promise(); }; var start = function(c) { quitOnAdFrames() .then(function() { return jqueryInit(c); }) .done(function() { s2cgGCMain(); }); }; function s2cgGCMain() { // this adds a column with send2cgeo button in search results table function addSend2cgeoColumn(field) { if (field == 0) { return; } var GCCode = $(field).html().match(/GC[A-Z0-9]{1,6}/)[0]; if ($('#s2cg-' + GCCode)[0]) { return; } var html = '
' + ' ' + ' Send to c:geo Send List' + '
' + '