Skip to content

Commit 24f5fc7

Browse files
capoairaLineflyer
authored andcommitted
Revert "cookie problem" (#2)
This reverts commit ab4edd0.
1 parent 76bfaff commit 24f5fc7

File tree

1 file changed

+28
-206
lines changed

1 file changed

+28
-206
lines changed

send2cgeo.user.js

Lines changed: 28 additions & 206 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,12 @@
1111
// @include /^https?://www\.geocaching\.com/my/recentlyviewedcaches\./
1212
// @include /^https?://www\.geocaching\.com/(map/|geocache/)/
1313
// @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/
1615
// @icon https://send2.cgeo.org/send2cgeo.png
1716
// @downloadURL https://github.com/cgeo/send2cgeo/raw/release/send2cgeo.user.js
1817
// @updateURL https://github.com/cgeo/send2cgeo/raw/release/send2cgeo.user.js
1918
// @supportURL https://github.com/cgeo/send2cgeo/issues
2019
// @version 0.51
21-
// @grant GM_setValue
22-
// @grant GM_getValue
2320
// ==/UserScript==
2421

2522
// Function that handles the actual sending
@@ -28,29 +25,20 @@ var s2cgScript = document.createElement('script');
2825
s2cgScript.type = 'text/javascript';
2926
s2cgScript.innerHTML = 'window.s2geo = function(GCCode) {'
3027
// 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+
+ ' );'
5442
+ '};';
5543

5644
document.getElementsByTagName('head')[0].appendChild(s2cgScript);
@@ -159,10 +147,6 @@ var start = function(c) {
159147
});
160148
};
161149

162-
function isUsePopUpWindow() {
163-
return GM_getValue('usePopUpWindow', false);
164-
}
165-
166150
function s2cgGCMain() {
167151
// check for premium membership (parts of the page content are different)
168152
function premiumCheck() {
@@ -323,50 +307,21 @@ function s2cgGCMain() {
323307
$(anchorElement).append(html);
324308

325309
$('#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",
329318
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();
350323
}
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+
);
370325
});
371326
}
372327

@@ -387,7 +342,6 @@ function s2cgGCMain() {
387342
+ '<iframe style="' + iframeStyle + '"></iframe>'
388343
+ '</div>');
389344

390-
// This function add the send2cgeo buttons on geocaching.com
391345
// Send to c:geo on browsemap (old map)
392346
if (document.location.href.match(/\.com\/map/)) {
393347
var template = $("#cacheDetailsTemplate").html();
@@ -629,138 +583,6 @@ function s2cgGCMain() {
629583

630584
oc.innerHTML = oc.innerHTML.replace('</p>', html);
631585
}
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(/\.de\/myhome\.php/) ? '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(/\.com\/account\/dashboard/)) {
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(/\.de\/myhome\.php/)) {
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-
}
764586
}
765587

766588
start(this);

0 commit comments

Comments
 (0)