Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Premium check for Geocaching.com #37

Merged
merged 5 commits into from
Jun 28, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions send2cgeo.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// @description Add button "Send to c:geo" to geocaching.com
// @author c:geo team and contributors
// @grant none
// @include https://www.geocaching.com/play/search*
// @include https://www.geocaching.com/play/search/*
// @include http://www.geocaching.com/seek/cache_details*
// @include https://www.geocaching.com/seek/cache_details*
Expand All @@ -27,9 +28,22 @@
// accessed.

var s = document.createElement('script');
var premium = document.getElementsByClassName('li-membership')[0];
if (premium.children[0].innerHTML == 'Upgrade') {
premium = false;

// check for premium membership (parts of the page content are different)
var premium;
if (document.getElementsByClassName('li-membership').length) {
premium = document.getElementsByClassName('li-membership')[0];
} else {
premium = document.getElementsByClassName('li-upgrade')[0];
}

// premium has an empty <li class="li-upgrade">
if (premium.children.length) {
// in case GC.com changes the content,
// it still has to contain only "Upgrade" string
if (premium.children[0].innerHTML == 'Upgrade') {
premium = false;
}
} else {
premium = true;
}
Expand Down