-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathsend2cgeo.user.js
666 lines (591 loc) · 28.3 KB
/
send2cgeo.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
// ==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 = '<td class="mobile-show">'
+ ' <a id="s2cg-' + GCCode + '" href="javascript:void(0);" onclick="window.s2geo(\'' + GCCode + '\'); return false;">'
+ ' <img height="50" src="https://www.cgeo.org/send2cgeo.png" border="0"> '
+ ' </a>'
+ '</td>';
$(field).parent().parent().before(html);
}
// waits for new elements (by ajax calls) injected into the DOM and calls a certain
// method for certain elements
// (here: used in search results - these are loaded lazyly when scrolling down)
window.waitForKeyElements = function(selectorTxt, actionFunction, bWaitOnce, iframeSelector) {
var targetNodes, btargetsFound;
if (typeof iframeSelector == "undefined") {
targetNodes = $(selectorTxt);
} else {
targetNodes = $(iframeSelector).contents().find(selectorTxt);
}
if (targetNodes && targetNodes.length > 0) {
btargetsFound = true;
// Found target node(s). Go through each and act if they are new
targetNodes.each(
function () {
var jThis = $(this);
var alreadyFound = jThis.data('alreadyFound') || false;
if (!alreadyFound) {
// Call the payload function
var cancelFound = actionFunction(jThis);
if (cancelFound) {
btargetsFound = false;
} else {
jThis.data('alreadyFound', true);
}
}
}
);
} else {
btargetsFound = false;
}
// Get the timer-control variable for this selector
var controlObj = waitForKeyElements.controlObj || {};
var controlKey = selectorTxt.replace (/[^\w]/g, "_");
var timeControl = controlObj[controlKey];
// Now set or clear the timer as appropriate
if (btargetsFound && bWaitOnce && timeControl) {
// The only condition where we need to clear the timer
clearInterval(timeControl);
delete controlObj[controlKey];
} else {
// Set a timer, if needed
if (! timeControl) {
timeControl = setInterval(
function () {
waitForKeyElements(selectorTxt, actionFunction, bWaitOnce, iframeSelector);
},
300
);
controlObj[controlKey] = timeControl;
}
}
waitForKeyElements.controlObj = controlObj;
}
// Remove element if it already exists
function removeIfAlreadyExists(name, elemToRemove) {
if ($(name)[0]) {
$(elemToRemove).remove();
}
}
// Send List
function sendList(list, i=0) {
if (list == undefined || list == null || (!Array.isArray(list) && list.length == 0)) {
return;
}
var GCCode = list[i];
var padding = i%10 * 30 + 10;
let sendCache = window.open(
'https://send2.cgeo.org/add.html?cache=' + GCCode,
'send' + GCCode,
'width=200,height=100,top=' + padding + ',left=' + padding + ',menubar=no,status=no,resizable=no;'
);
window.setTimeout(
function() {
sendCache.close();
},
3000
);
$('#s2cg_send_process').html((i+1) + '/' + list.length + ' caches sent');
if (i+1 < list.length) {
window.setTimeout(
function () {
sendList(list, i+1);
},
100
)
}
}
// This function add the send2cgeo buttons on geocaching.com
// Because jQuery is not supported by some pages, the window.s2geo() function does not work.
// The following function is a workaround to solve this problem.
function buildButton(GCCode, anchor, height, imgClass='') {
// Add s2cg button.
var html = '<a id="s2cg-' + GCCode + '" href="javascript:void(0);" title="Send to c:geo">'
+ '<img class="' + imgClass + '" src="https://www.cgeo.org/send2cgeo.png" height="' + height + '"/>'
+ '</a>';
$(anchor).append(html);
$('#s2cg-' + GCCode).on('click', function() {
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
);
});
}
// This function add the send2cgeo buttons on geocaching.com
// Send to c:geo on browsemap (old map)
if (document.location.href.match(/\.com\/map/)) {
var template = $("#cacheDetailsTemplate").html();
var html = '<a href="javascript:void(0);" onclick="window.s2geo(\'{{=gc}}\'); return false;">'
+ '<img height="16px" src="https://www.cgeo.org/send2cgeo.png" />'
+ '<span>Send to c:geo</span></a>';
var searchpos = template.indexOf('/images/icons/16/write_log.png');
var pos = template.indexOf('</a>', searchpos) + 4;
template = template.substring(0, pos) + html + template.substring(pos, template.length);
$("#cacheDetailsTemplate").html(template);
}
// Send to c:geo on seachmap (new map)
if (document.location.href.match(/\.com\/play\/map/)) {
function addButtonPopup() {
window.setTimeout(
function () {
if ($('.leaflet-popup-content')[0]) {
var GCCode = $('.cache-action-open-cache')[0].href.match(/GC[A-Z0-9]{1,6}/);
if ($('#s2cg_' + GCCode)[0]) return;
// Remove button when the GCCode has change
removeIfAlreadyExists('.cache-action-menu-view ul li.s2cg', $('.cache-action-menu-view ul li.s2cg'));
$('.cache-action-menu-view ul').append('<li id="s2cg_' + GCCode + '" class="s2cg"></li>');
buildButton(GCCode, $('.cache-action-menu-view ul li.s2cg'), '0', 'hidden');
$('.cache-action-menu-view ul li.s2cg a').append('<span>Send to c:geo</span>');
}
},
100
);
}
function addButtonSidebar() {
if ($('.cache-preview-action-menu')[0]) {
var GCCode = $('.cache-metadata-code').html();
// Remove button when the GCCode has change
if ($('#s2cg_' + GCCode)[0]) return;
removeIfAlreadyExists('.cache-preview-action-menu ul li.s2cg', $('.cache-preview-action-menu ul li.s2cg'));
$('.cache-preview-action-menu ul').append('<li id="s2cg_' + GCCode + '" class="s2cg"></li>');
buildButton(GCCode, $('.cache-preview-action-menu ul li.s2cg'), '25px', 'action-icon');
$('.cache-preview-action-menu ul li.s2cg a').append('<span>Send to c:geo</span>');
}
}
// observer callback for checking existence of sidebar
var cb_body = function(mutationsList, observer) {
observer_body.disconnect();
addButtonPopup();
if ($('div#sidebar')[0] && !$('.s2cg_sidebar_observer')[0]) {
$('div#sidebar').addClass('s2cg_sidebar_observer');
// start observing sidebar for switches between search list and cache details view
var target_sidebar = $('div#sidebar')[0];
var config_sidebar = {
childList: true,
subtree: true
};
observer_sidebar.observe(target_sidebar, config_sidebar);
}
observer_body.observe(target_body, config_body);
}
// observer callback when sidebar switches between search list and cache details view
var cb_sidebar = function(mutationsList, observer) {
observer_sidebar.disconnect();
addButtonSidebar()
var target_sidebar = $('div#sidebar')[0];
var config_sidebar = {
childList: true,
subtree: true
};
observer_sidebar.observe(target_sidebar, config_sidebar);
}
// create observer instances linked to callback functions
var observer_body = new MutationObserver(cb_body);
var observer_sidebar = new MutationObserver(cb_sidebar); // ATTENTION: the order matters here
var target_body = $('body')[0];
var config_body = {
childList: true,
attributes: true
};
observer_body.observe(target_body, config_body);
}
// Send to c:geo on new seachpage
if (document.location.href.match(/\.com\/play\/search/)) {
window.waitForKeyElements(".cache-details", addSend2cgeoColumn, false);
function getGCCodes(number, skipFound) {
var skiped = 0;
var gccodes = new Array();
var loadMore = true;
var numberOfAllCaches = $('.controls-header').html().replace(/[\.,]/g, '').match(/\d{1,}/);
var maxCaches = (numberOfAllCaches >= 1000 ? 1000 : numberOfAllCaches);
function addGCCode(i, skipFound) {
let tr = $('#geocaches tr')[i];
if (tr) {
loadMore = true;
if (!skipFound || (skipFound && (!$(tr).find('svg.badge')[0] || !$(tr).find('svg.badge use').attr('xlink:href').match(/#icon-found/)))) {
gccodes.push($(tr).attr('data-id'));
} else {
skiped++;
}
$('#s2cg_send_process').html((number == 0 ? 0 : (i+1-skiped)) + '/' + number + ' caches load');
if (i+1 < number+skiped) {
addGCCode(i+1, skipFound);
} else {
// All Caches Load
sendList(gccodes);
}
} else {
function waitAndAdd(i, skipFound) {
window.setTimeout(
function () {
addGCCode(i, skipFound);
},
300
);
}
if ($('#loadmore')[0] && loadMore) {
loadMore = false;
$('#loadmore').click();
waitAndAdd(i, skipFound)
} else {
if (i == maxCaches) {
// The maximum of 1000 caches is load
$('#s2cg_send_process').html('The maximum number of caches has been loaded.');
window.setTimeout(
function () {
sendList(gccodes);
},
500
);
} else {
waitAndAdd(i, skipFound);
}
}
}
}
addGCCode(0, skipFound);
}
$('#searchResultsTable').before(
'<div>Send2cgeo: '
+ ' <a href="javascript:void(0);" id="send_50">50</a> '
+ ' <a href="javascript:void(0);" id="send_100">100</a> '
+ ' <a href="javascript:void(0);" id="send_200">200</a> '
+ ' <a href="javascript:void(0);" id="send_500">500</a> '
+ ' <a href="javascript:void(0);" id="send_1000">1000</a> '
+ ' <label style="display:block"><input type="checkbox" id="send2cgeo_skip_found" name="send2cgeo_skipt_found"><span>Skip found caches</span></label>'
+ ' <div id="s2cg_send_process"></div>'
+ '</div>'
);
$('#send_50').on('click', function() {
getGCCodes(50, $('#send2cgeo_skip_found').is(':checked'));
});
$('#send_100').on('click', function() {
getGCCodes(100, $('#send2cgeo_skip_found').is(':checked'));
});
$('#send_200').on('click', function() {
getGCCodes(200, $('#send2cgeo_skip_found').is(':checked'));
});
$('#send_500').on('click', function() {
getGCCodes(500, $('#send2cgeo_skip_found').is(':checked'));
});
$('#send_1000').on('click', function() {
getGCCodes(1000, $('#send2cgeo_skip_found').is(':checked'));
});
// Send2cgeo column header for func addSend2cgeoColumn
var S2CGHeader = '<th class="mobile-show"><a class="outbound-link">Send to c:geo</a></th>';
$("#searchResultsTable .cache-primary-details-th").before(S2CGHeader);
$("#searchResultsTable .col-primary").before('<col></col>');
$('head').append('<style type="text/css">tr[data-premium] td + td {padding-top: 0 !important;}</style>');
var caches = $(".cache-details");
caches.each(addSend2cgeoColumn);
}
// Send to c:geo on cache detail page
if (document.location.href.match(/\.com\/(seek\/cache_details\.aspx|geocache\/)/)) {
var GCCode = $("#ctl00_ContentBody_CoordInfoLinkControl1_uxCoordInfoCode").html();
var html2 = '<dt><a href="javascript:void(0);" onclick="window.s2geo(\'' + GCCode + '\'); return false;" style="display:flex;">'
+ '<img src="https://www.cgeo.org/send2cgeo.png" title="Send to c:geo" height="16px" />'
+ '<span>Send to c:geo</span></a></dt>';
$("#Download dd:last").append(html2);
}
// Send to c:geo on recentlyviewed and nearest list
if (document.location.href.match(/\.com\/seek\/nearest\.aspx/) || document.location.href.match(/\.com\/my\/recentlyviewedcaches\.aspx/)) {
$('.BorderTop th').first().after('<th><img src="https://www.cgeo.org/send2cgeo.png" title="Send to c:geo" height="20px" /></th>');
$('.Data.BorderTop').each(
function() {
var GCCode = $(this).find(".Merge").last().find("span.small").first().text().match(/GC[A-Z0-9]{1,6}/)[0];
var html = '<td><a href="javascript:void(0);" onclick="window.s2geo(\'' + GCCode + '\'); return false;">'
+ ' <img src="https://www.cgeo.org/send2cgeo.png" title="Send to c:geo" height="20px" />'
+ '</a></td>';
$(this).find('td').first().after(html);
}
);
}
// Send to c:geo on new List / new BML
if (document.location.href.match(/\.com\/plan\/lists\/BM/)) {
// observer callback
let cb = function() {
// add buttons if table has been loaded
if ($('div.footer-pagination-container').length > 0) {
addButtons();
}
}
// observe body for changes of child nodes
let target = $('body')[0];
let config = {
childList: true,
subtree: true
};
let observer = new MutationObserver(cb);
observer.observe(target, config);
function addButtons() {
// stop observing during adding the buttons
observer.disconnect();
if ($('.multi-select-action-bar')[0]) {
removeIfAlreadyExists('#s2cg_selected', $('#s2cg_selected'));
$('.multi-select-action-bar-count-section').after('<a id="s2cg_selected" href="javascript:void(0);">'
+ ' <img src="https://www.cgeo.org/send2cgeo.png" title="Send to c:geo" height="45px" style="margin-right:8px" />'
+ '</a>');
$('#s2cg_selected').on('click', function() {
var caches = $.find('.geocache-table tbody tr input[type="checkbox"]:checked');
var gccodes = new Array();
$(caches).each(
function() {
let GCCode = $(this).parents('tr').find('.geocache-code').text().match(/GC[A-Z0-9]{1,6}/)[0];
gccodes.push(GCCode);
}
);
sendList(gccodes);
});
if (!$('#s2cg_send_process')[0] || $('#s2cg_send_process').html() == '') {
$('.section-controls').after('<div id="s2cg_send_process"></div>');
}
}
removeIfAlreadyExists('.header-s2cg', $('.header-s2cg'));
$('.geocache-table thead th:nth-child(2)').before('<th class="header-s2cg"><img src="https://www.cgeo.org/send2cgeo.png" title="Send to c:geo" height="20px" /></th>');
$('.geocache-table tbody tr').each(
function() {
if ($(this).find('iframe')[0]) {
return;
}
if (!$(this).find('.geocache-code')[0]) { // return if there is a comment for the cache
if (!$(this).find('.s2cg')[0]) {
$(this).find('.cache-description').before('<td class="s2cg"></td>');
}
return;
}
var GCCode = $(this).find('.geocache-code').text().match(/GC[A-Z0-9]{1,6}/)[0];
removeIfAlreadyExists('#s2cg-' + GCCode, $('#s2cg-' + GCCode).parent());
$(this).find('td.cell-geocache-name').before('<td class="s2cg"></td>');
buildButton(GCCode, $(this).find('td.s2cg'), '20px');
}
);
// continue observing
observer.observe(target, config);
}
}
if (document.location.href.match(/\.com\/play\/owner/)) {
// observer callback
let cb = function() {
// add buttons if table has been loaded
if ($('.geocache-table tbody tr').length > 0) {
addButtons();
}
}
// observe body for changes of child nodes
let target = $('body')[0];
let config = {
childList: true,
subtree: true
};
let observer = new MutationObserver(cb);
observer.observe(target, config);
function addButtons() {
// stop observing during adding the buttons
observer.disconnect();
removeIfAlreadyExists('.header-s2cg', $('.header-s2cg'));
$('.geocache-table thead th').first().before('<th class="header-s2cg"><img src="https://www.cgeo.org/send2cgeo.png" title="Send to c:geo" height="20px" /></th>');
$('.geocache-table tbody tr').each(
function() {
var GCCode = $(this).find('.geocache-details').text().match(/GC[A-Z0-9]{1,6}/)[0];
removeIfAlreadyExists('#s2cg-' + GCCode, $('#s2cg-' + GCCode).parent());
$(this).find('td.name-display').before('<td class="s2cg"></td>');
buildButton(GCCode, $(this).find('td.s2cg'), '20px');
}
);
// continue observing
observer.observe(target, config);
}
}
// This function add the send2cgeo buttons on opencaching.de
// Send to c:geo on viewcache
if (document.location.href.match(/\.de\/viewcache\.php/)) {
var oc = document.getElementsByClassName('exportlist')[0].parentNode.parentNode;
var occode = document.title.match(/OC[A-Z0-9]{1,6}/)[0];
var html = '<img src="https://www.cgeo.org/send2cgeo.png" height="16px" />'
+ '<a href="javascript:void(0);" onclick="window.s2geo(\'' + occode + '\'); return false;" > '
+ '<input class="exportbutton" type="button" value="An c:geo senden" title="An c:geo senden" /></a> '
+ '</p>';
oc.innerHTML = oc.innerHTML.replace('</p>', html);
}
// Bild a s2cg popup
var popupHTML = '<div id="s2cg_popup" style="display:none;">'
+ ' <div id="s2cg_popup_content">'
+ ' </div>'
+ '</div>';
function closePupup() {
$('#s2cg_popup').css('display', 'none');
}
var sendMultipleHTML = '<div id="s2cg_popup_close">X</div>'
+ '<div id="s2cg_popup_header">'
+ ' <h1>Send Multiple Caches</h1>'
+ '</div>'
+ '<textarea id="s2cg_send_input"></textarea>'
+ '<div id="s2cg_send_process"></div>'
+ '<div id="s2cg_send_frames" style="display:none;"></div>'
+ '<input type="button" id="s2cg_send_submit" class="s2cg_btn_submit" value="Send">';
var settingsCSS = '#s2cg_popup {'
+ ' position: fixed;'
+ ' background: rgba(31, 31, 31, .7);'
+ ' top: 0;'
+ ' left: 0;'
+ ' width: 100%;'
+ ' height: 100%;'
+ ' z-index: 1111;'
+ ' color: #fff;'
+ '}'
+ '#s2cg_popup_close {'
+ ' position:absolute;'
+ ' top:10px;'
+ ' right:10px;'
+ ' font-weight: bold;'
+ ' cursor: pointer;'
+ '}'
+ '#s2cg_popup_content {'
+ ' position: absolute;'
+ ' top: 50%;'
+ ' left: 50%;'
+ ' width: 60%;'
+ ' -webkit-transform: translate(-50%, -50%);'
+ ' -ms-transform: translate(-50%, -50%);'
+ ' transform: translate(-50%, -50%);'
+ ' background: rgba(31, 31, 31, 1);'
+ ' padding: 1em;'
+ ' border-radius: 1em;'
+ '}'
+ '#s2cg_send_input {'
+ ' color:#000;'
+ ' width:100%;'
+ ' min-height:200px;'
+ '}'
+ '#s2cg_popup_content p, .s2cg_toggle label, .s2cg_btn_submit, #s2cg_send_input, #s2cg_send_process, #s2cg_popup_close {'
+ ' font-size: ' + (document.location.href.match(/\.de\/myhome\.php/) ? '1.5' : '1') + 'em !important;'
+ '}'
+ '.s2cg_btn_submit {'
+ ' margin-top: 1em;'
+ ' color: rgba(31, 31, 31, 1);'
+ ' border-radius: 5px;'
+ ' cursor: pointer;'
+ ' padding: 0 8px;'
+ '}'
if (document.location.href.match(/\.com\/account\/dashboard/) || document.location.href.match(/\.com\/my\/default.aspx/) || document.location.href.match(/\.de\/myhome\.php/)) {
$('head').append('<style>' + settingsCSS + '</style>');
$('body').append(popupHTML);
// geocaching.com
// new Dashboard
if (document.location.href.match(/\.com\/account\/dashboard/)) {
$('.bio-meta').append('<span style="display:block;">Send to c:geo <a id="s2cg_open_sendList" href="javascript:void(0)">Send List</a></span>');
}
// old Dashboard
if (document.location.href.match(/\.com\/my\/default.aspx/)) {
$('#ctl00_ContentBody_WidgetMiniProfile1_memberProfileLink').parent().append(' | Send to c:geo <a id="s2cg_open_sendList" href="javascript:void(0)">Send List</a>');
}
// opencaching.de
if (document.location.href.match(/\.de\/myhome\.php/)) {
$('.content2-pagetitle').after('<div class="content2-container bg-blue02" style="margin-top:20px;">'
+ ' <p class="content-title-noshade-size3">'
+ ' <img src="https://www.cgeo.org/send2cgeo.png" style="margin-right:10px;" height="22px" />'
+ ' Send to c:geo <span class="content-title-link"><a id="s2cg_open_sendList" href="javascript:void(0)">Send List</a></span>'
+ ' </p>'
+ '</div>');
}
// Open and Send multiple caches
$('#s2cg_open_sendList').on('click', function() {
$('#s2cg_popup_content').html(sendMultipleHTML);
$('#s2cg_popup').css('display', 'unset');
$('#s2cg_send_submit').on('click', function() {
var gccodes = $('#s2cg_send_input').val().match(/(GC|OC)[A-Z0-9]{1,6}/gi);
$(gccodes).each(
function () {
$('#s2cg_send_frames').append('<div><span id="s2cg-' + this + '"></span></div>');
}
);
sendList(gccodes);
});
$('#s2cg_popup_close').on('click', closePupup);
});
}
}
start(this);