CustomsForge min songs filter

Add minimum songs filter to CustomsForge artist search

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 or Violentmonkey 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         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();
            }
        });
    }
}