Achievement Filter

Filter cheevos on the cheevo page.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

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

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         Achievement Filter
// @namespace    pxgamer
// @version      0.7
// @description  Filter cheevos on the cheevo page.
// @author       pxgamer
// @include      *kat.cr/achievements/
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var year = new Date().getFullYear();

    var assigned   = $('table.achTable tbody tr td.width100perc ul li span.achBadge.assignedAchievement').length;
    var unassigned = $('table.achTable tbody tr td.width100perc ul li span.achBadge').length - assigned;

    $('table.achTable').before('<div style="margin-bottom: 5px;"><span class="showAllCheevos kaButton smallButton normalText">Show All</span> <span class="showOnlyCollected kaButton smallButton normalText">Show Only Achieved ('+assigned+')</span> <span class="showNonCollected kaButton smallButton normalText">Show Non-Collected Achievements ('+unassigned+')</span> <span class="showCurrentCheevos kaButton smallButton normalText">Show Current Achievements</span></div><hr>');

    // Only show achievements you've already got
    $('.showOnlyCollected').on('click', function() {
        $('table.achTable tbody tr td.width100perc ul li').each(function() {
            $(this).show();
        });
        $('table.achTable tbody tr td.width100perc ul li span.achBadge').each(function() {
            if (!$(this).hasClass('assignedAchievement')) {
                $(this).parent().hide();
            }
        });
    });

    // Only show achievements you haven't got
    $('.showNonCollected').on('click', function() {
        $('table.achTable tbody tr td.width100perc ul li').each(function() {
            $(this).show();
        });
        $('table.achTable tbody tr td.width100perc ul li span.achBadge').each(function() {
            if ($(this).hasClass('assignedAchievement')) {
                $(this).parent().hide();
            }
        });
    });

    // Only current achievements
    $('.showCurrentCheevos').on('click', function() {
        $('table.achTable tbody tr td.width100perc ul li').each(function() {
            $(this).show();
        });
        $('table.achTable tbody tr td.width100perc ul li span.achBadge').each(function() {
            if (!$(this).hasClass('assignedAchievement') && $(this).children('a').children('span.achTitle').text().substring(0, 4) < year) {
                $(this).parent().hide();
            }
            if (!$(this).hasClass('assignedAchievement') && $(this).children('a').children('span.achTitle').text().substring($(this).children('a').children('span.achTitle').text().length - 4) < year) {
                $(this).parent().hide();
            }
        });
    });

    // Show all cheevos (reset)
    $('.showAllCheevos').on('click', function() {
        $('table.achTable tbody tr td.width100perc ul li').each(function() {
            $(this).show();
        });
    });
})();