Toggle Archived Geocaches

Adds a button to the Owned Caches page to toggle between hiding/showing archived caches

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Toggle Archived Geocaches
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Adds a button to the Owned Caches page to toggle between hiding/showing archived caches
// @author       Michel ten Voorde
// @match        https://www.geocaching.com/my/owned.aspx*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var notArchived = 0;

	$('.MyOwnedCachesTable').before('<a id="toggleArchivedBtn" class="btn btn-primary" style="margin-top: 14px; background-color: #17a2b8" data-show="true"><span id="hideShowToggle">Hide</span> archived caches</a>');

    $('#toggleArchivedBtn').click(function() {
        if ($('#toggleArchivedBtn').data('show') === true) {
            $('#hideShowToggle').text('Show');
            $('#toggleArchivedBtn').data('show', false);
            $('a.OldWarning').parent().parent().hide(500);

            if (notArchived === 0) {
                notArchived = $('table.MyOwnedCachesTable tr.UserOwned').length - $('a.OldWarning').parent().parent().length;
                $("#ctl00_ContentBody_lbHeading").text($("#ctl00_ContentBody_lbHeading").text() + ", of which " + notArchived + " are active.");
            }
        } else {
            $('#hideShowToggle').text('Hide');
            $('#toggleArchivedBtn').data('show', true);
            $('a.OldWarning').parent().parent().show(500);
        }
    });
})();