CustomsForge min songs filter

Add minimum songs filter to CustomsForge artist search

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         CustomsForge min songs filter
// @license      WTFPL; http://www.wtfpl.net/
// @namespace    http://ttmyller.azurewebsites.net/
// @version      0.1
// @description  Add minimum songs filter to CustomsForge artist search
// @author       Teemu Myller
// @match        http://ignition.customsforge.com/search/artists
// @require      https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var minSongs = $('<span>Min songs: &nbsp; <select id="minSongs" /> &nbsp; </span>');
    var select = $('#minSongs', minSongs);
    for (var i=1; i<=50; i++) {
        $('<option value="' + i + '">' + i + '</option>').appendTo(select);
    }
    select.change(function() { hideArtistsWithSongsLessThan(this.value); });
    $('nav', '#content-header-artists').prepend(minSongs);
})();

function hideArtistsWithSongsLessThan(count) {
    if (count < 1) {
        $('a', '#artists-column').show();
    } else {
        var regex = /\((\d+)\)/;
        $('a', '#artists-column').each(function() {
            var item = $(this);
            var songs = parseInt(item.text().match(regex)[1]);
            if (songs < count) {
                item.hide();
            } else {
                item.show();
            }
        });
    }
}