11
11
// @include /^https?://www\.geocaching\.com/my/recentlyviewedcaches\./
12
12
// @include /^https?://www\.geocaching\.com/(map/|geocache/)/
13
13
// @include /^https?://www\.geocaching\.com/plan/lists/
14
- // @include /^https?://www\.geocaching\.com/account/dashboard/
15
- // @include /^https?://www\.opencaching\.de/(viewcache|myhome).php/
14
+ // @include /^https?://www\.opencaching\.de/viewcache.php/
16
15
// @icon https://send2.cgeo.org/send2cgeo.png
17
16
// @downloadURL https://github.com/cgeo/send2cgeo/raw/release/send2cgeo.user.js
18
17
// @updateURL https://github.com/cgeo/send2cgeo/raw/release/send2cgeo.user.js
19
18
// @supportURL https://github.com/cgeo/send2cgeo/issues
20
19
// @version 0.51
21
- // @grant GM_setValue
22
- // @grant GM_getValue
23
20
// ==/UserScript==
24
21
25
22
// Function that handles the actual sending
@@ -28,29 +25,20 @@ var s2cgScript = document.createElement('script');
28
25
s2cgScript . type = 'text/javascript' ;
29
26
s2cgScript . innerHTML = 'window.s2geo = function(GCCode) {'
30
27
// show the box and the "please wait" text
31
- + ( isUsePopUpWindow ( )
32
- ? " 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');"
33
- + ' window.setTimeout('
34
- + ' function() {'
35
- + ' sendCache.close();'
36
- + ' },'
37
- + ' 3000'
38
- + ' )'
39
- : '$("#send2cgeo, #send2cgeo div").fadeIn();'
40
- // hide iframe for now and wait for page to be loaded
41
- + '$("#send2cgeo iframe")'
42
- + ' .hide()'
43
- + ' .off("load")'
44
- + ' .attr("src", "https://send2.cgeo.org/add.html?cache=" + GCCode)'
45
- + ' .on("load",'
46
- + ' function() {'
47
- // hide "please wait text" and show iframe
48
- + ' $("#send2cgeo div").hide();'
49
- // hide box after 3 seconds
50
- + ' $(this).css("display", "block").parent().delay(3000).fadeOut();'
51
- + ' }'
52
- + ' );'
53
- )
28
+ + '$("#send2cgeo, #send2cgeo div").fadeIn();'
29
+ // hide iframe for now and wait for page to be loaded
30
+ + '$("#send2cgeo iframe")'
31
+ + ' .hide()'
32
+ + ' .off("load")'
33
+ + ' .attr("src", "https://send2.cgeo.org/add.html?cache=" + GCCode)'
34
+ + ' .on("load",'
35
+ + ' function() {'
36
+ // hide "please wait text" and show iframe
37
+ + ' $("#send2cgeo div").hide();'
38
+ // hide box after 3 seconds
39
+ + ' $(this).css("display", "block").parent().delay(3000).fadeOut();'
40
+ + ' }'
41
+ + ' );'
54
42
+ '};' ;
55
43
56
44
document . getElementsByTagName ( 'head' ) [ 0 ] . appendChild ( s2cgScript ) ;
@@ -159,10 +147,6 @@ var start = function(c) {
159
147
} ) ;
160
148
} ;
161
149
162
- function isUsePopUpWindow ( ) {
163
- return GM_getValue ( 'usePopUpWindow' , false ) ;
164
- }
165
-
166
150
function s2cgGCMain ( ) {
167
151
// check for premium membership (parts of the page content are different)
168
152
function premiumCheck ( ) {
@@ -323,50 +307,21 @@ function s2cgGCMain() {
323
307
$ ( anchorElement ) . append ( html ) ;
324
308
325
309
$ ( '#s2cg-' + GCCode ) . on ( 'click' , function ( ) {
326
- if ( isUsePopUpWindow ( ) ) {
327
- 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' ) ;
328
- window . setTimeout (
310
+ // show the box and the "please wait" text
311
+ $ ( "#send2cgeo, #send2cgeo div" ) . fadeIn ( ) ;
312
+ // hide iframe for now and wait for page to be loaded
313
+ $ ( "#send2cgeo iframe" )
314
+ . hide ( )
315
+ . off ( "load" )
316
+ . attr ( "src" , "https://send2.cgeo.org/add.html?cache=" + GCCode )
317
+ . on ( "load" ,
329
318
function ( ) {
330
- sendCache . close ( ) ;
331
- } ,
332
- 3000
333
- ) ;
334
- /* $(sendCache.document).ready(function () {
335
- function checkForContent(waitCount) {
336
- if ($(sendCache.document).contents().find('body').html() != '') {
337
- var body = $(sendCache.document).contents().find('body').html();
338
- console.log(body);
339
- } else {
340
- waitCount++;
341
- if (waitCount <= 200) {
342
- setTimeout(
343
- function() {
344
- checkForContent(waitCount);
345
- },
346
- 50
347
- );
348
- }
349
- }
319
+ // hide "please wait text" and show iframe
320
+ $ ( "#send2cgeo div" ) . hide ( ) ;
321
+ // hide box after 3 seconds
322
+ $ ( this ) . css ( "display" , "block" ) . parent ( ) . delay ( 3000 ) . fadeOut ( ) ;
350
323
}
351
- checkForContent(0);
352
- });*/
353
- } else {
354
- // show the box and the "please wait" text
355
- $ ( "#send2cgeo, #send2cgeo div" ) . fadeIn ( ) ;
356
- // hide iframe for now and wait for page to be loaded
357
- $ ( "#send2cgeo iframe" )
358
- . hide ( )
359
- . off ( "load" )
360
- . attr ( "src" , "https://send2.cgeo.org/add.html?cache=" + GCCode )
361
- . on ( "load" ,
362
- function ( ) {
363
- // hide "please wait text" and show iframe
364
- $ ( "#send2cgeo div" ) . hide ( ) ;
365
- // hide box after 3 seconds
366
- $ ( this ) . css ( "display" , "block" ) . parent ( ) . delay ( 3000 ) . fadeOut ( ) ;
367
- }
368
- ) ;
369
- }
324
+ ) ;
370
325
} ) ;
371
326
}
372
327
@@ -387,7 +342,6 @@ function s2cgGCMain() {
387
342
+ '<iframe style="' + iframeStyle + '"></iframe>'
388
343
+ '</div>' ) ;
389
344
390
- // This function add the send2cgeo buttons on geocaching.com
391
345
// Send to c:geo on browsemap (old map)
392
346
if ( document . location . href . match ( / \. c o m \/ m a p / ) ) {
393
347
var template = $ ( "#cacheDetailsTemplate" ) . html ( ) ;
@@ -629,138 +583,6 @@ function s2cgGCMain() {
629
583
630
584
oc . innerHTML = oc . innerHTML . replace ( '</p>' , html ) ;
631
585
}
632
-
633
- // This will add settings
634
- function save_settings ( ) {
635
- GM_setValue ( 'usePopUpWindow' , $ ( '#usePopUpWindow' ) . is ( ':checked' ) ) ;
636
- }
637
-
638
- var settingsHTML = '<div id="send2cgeo_settings" style="display:none;">'
639
- + ' <div id="s2cg_settings_content">'
640
- + ' <p>If third party cookies are not allowed, the script will not work. This can be avoided by displaying send2cgeo in a popup window.</p>'
641
- + ' <div class="toggle">'
642
- + ' <label>Use send2cgeo with a popup window'
643
- + ' <input type="checkbox" id="usePopUpWindow"' + ( isUsePopUpWindow ( ) ? ' checked' : '' ) + '><span class="slider"></span>'
644
- + ' </label>'
645
- + ' </div>'
646
- + ' <input type="button" id="send2cgeo_settings_submit" value="Save">'
647
- + ' </div>'
648
- + '</div>' ;
649
-
650
- var settingsCSS = '#send2cgeo_settings {'
651
- + ' position: fixed;'
652
- + ' background: rgba(31, 31, 31, .7);'
653
- + ' top: 0;'
654
- + ' left: 0;'
655
- + ' width: 100%;'
656
- + ' height: 100%;'
657
- + ' z-index: 1111;'
658
- + ' color: #fff;'
659
- + '}'
660
-
661
- + '#s2cg_settings_content {'
662
- + ' position: absolute;'
663
- + ' top: 50%;'
664
- + ' left: 50%;'
665
- + ' -webkit-transform: translate(-50%, -50%);'
666
- + ' -ms-transform: translate(-50%, -50%);'
667
- + ' transform: translate(-50%, -50%);'
668
- + ' background: rgba(31, 31, 31, 1);'
669
- + ' padding: 1em;'
670
- + ' border-radius: 1em;'
671
- + '}'
672
-
673
- + '#s2cg_settings_content p, .toggle label, #send2cgeo_settings_submit {'
674
- + ' font-size: ' + ( document . location . href . match ( / \. d e \/ m y h o m e \. p h p / ) ? '1.5' : '1' ) + 'em !important;'
675
- + '}'
676
-
677
- + '#send2cgeo_settings_submit {'
678
- + ' margin-top: 1em;'
679
- + ' color: rgba(31, 31, 31, 1);'
680
- + ' border-radius: 5px;'
681
- + ' cursor: pointer;'
682
- + ' padding: 0 8px;'
683
- + '}'
684
-
685
- + '.toggle {'
686
- + ' padding-left: 1em;'
687
- + '}'
688
-
689
- + '.toggle label {'
690
- + ' position: relative;'
691
- + ' display: inline-block;'
692
- + ' text-transform: none;'
693
- + '}'
694
-
695
- + '.toggle input {'
696
- + ' display: none;'
697
- + '}'
698
-
699
- + '.toggle .slider {'
700
- + ' position: absolute;'
701
- + ' cursor: pointer;'
702
- + ' margin-left: .5em;'
703
- + ' width: 2em;'
704
- + ' height: 1em;'
705
- + ' background: #c32e04; /* red */'
706
- + ' transition: all .3s ease-in-out;'
707
- + ' border-radius: 1em;'
708
- + '}'
709
-
710
- + '.toggle .slider:before {'
711
- + ' position: absolute;'
712
- + ' content: "";'
713
- + ' height: .6em;'
714
- + ' width: .6em;'
715
- + ' left: .2em;'
716
- + ' bottom: .2em;'
717
- + ' background: white;'
718
- + ' border-radius: 50%;'
719
- + ' transition: all .3s ease-in-out;'
720
- + '}'
721
-
722
- + '.toggle input:checked + .slider {'
723
- + ' background: #5a9900; /* green */'
724
- + '}'
725
-
726
- + '.toggle input:checked + .slider:before {'
727
- + ' -webkit-transform: translateX(1em);'
728
- + ' -ms-transform: translateX(1em);'
729
- + ' transform: translateX(1em);'
730
- + '}' ;
731
-
732
- // geocaching.com
733
- if ( document . location . href . match ( / \. c o m \/ a c c o u n t \/ d a s h b o a r d / ) ) {
734
- $ ( 'head' ) . append ( '<style>' + settingsCSS + '</style>' ) ;
735
- $ ( 'body' ) . append ( settingsHTML ) ;
736
- $ ( '.bio-meta' ) . append ( '<a id="s2cg_openSettings" href="javascript:void(0)" style="display:block;">Send2cgeo Settings</a>' ) ;
737
- $ ( '#send2cgeo_settings_submit' ) . on ( 'click' , function ( ) {
738
- save_settings ( ) ;
739
- $ ( '#send2cgeo_settings' ) . css ( 'display' , 'none' ) ;
740
- } ) ;
741
- $ ( '#s2cg_openSettings' ) . on ( 'click' , function ( ) {
742
- $ ( '#send2cgeo_settings' ) . css ( 'display' , 'unset' ) ;
743
- } ) ;
744
- }
745
-
746
- // opencaching.de
747
- if ( document . location . href . match ( / \. d e \/ m y h o m e \. p h p / ) ) {
748
- $ ( 'head' ) . append ( '<style>' + settingsCSS + '</style>' ) ;
749
- $ ( 'body' ) . append ( settingsHTML ) ;
750
- $ ( '.content2-pagetitle' ) . after ( '<div class="content2-container bg-blue02" style="margin-top:20px;">'
751
- + ' <p class="content-title-noshade-size3">'
752
- + ' <img src="https://send2.cgeo.org/send2cgeo.png" style="margin-right:10px;" height="22px" />'
753
- + ' Send2cgeo <span class="content-title-link"><a id="s2cg_openSettings" href="javascript:void(0)">Settings</a></span>'
754
- + ' </p>'
755
- + '</div>' ) ;
756
- $ ( '#send2cgeo_settings_submit' ) . on ( 'click' , function ( ) {
757
- save_settings ( ) ;
758
- $ ( '#send2cgeo_settings' ) . css ( 'display' , 'none' ) ;
759
- } ) ;
760
- $ ( '#s2cg_openSettings' ) . on ( 'click' , function ( ) {
761
- $ ( '#send2cgeo_settings' ) . css ( 'display' , 'unset' ) ;
762
- } ) ;
763
- }
764
586
}
765
587
766
588
start ( this ) ;
0 commit comments