Filter user uploads by type

Filter user uploads by their type

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Filter user uploads by type
// @namespace    pxgamer
// @version      0.1
// @description  Filter user uploads by their type
// @author       pxgamer
// @include      *kat.cr/user/*/uploads/
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var types      = ["exeType", "zipType", "pdfType", "filmType", "musicType", "pictureType", "undefinedType"];
    var typesNames = ["Application", "Archived", "Book", "Film", "Music", "Pictures", "Undefined"];
    var typeHTML   = "";

    for (var i = 0; i < types.length; i++) {
        typeHTML = typeHTML + '<option value="'+types[i]+'">'+typesNames[i]+'</option>';
    }

    $('h2').after(' <select id="tfilter">'+typeHTML+'</select> <button class="siteButton bigButton filterTypes ka ka-search"></button>');
    $('.filterTypes').on('click', function() {
        var type = $('#tfilter').val();

        $('tr td div.torrentname div a.cellMainLink').each(function() {
            $(this).parent().parent().parent().parent().show();
        });

        $('tr td div.torrentname div a.cellMainLink').each(function() {
            if (!$(this).parent().hasClass(type)) {
                $(this).parent().parent().parent().parent().hide();
            }
        });
    });
})();