Lernu.net vortaro filtrilo

Filtras la lingvojn de la lernu.net vortaro

// ==UserScript==
// @name         Lernu.net vortaro filtrilo
// @namespace    
// @version      0.6
// @description  Filtras la lingvojn de la lernu.net vortaro
// @author       panicbit
// @match        http://*.lernu.net/cgi-bin/vortaro.pl
// @require      https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.0.3/js.cookie.min.js
// @grant        none
// ==/UserScript==

// Fix prototype.js JSON crap
// Kudos to https://github.com/mozilla/jschannel/pull/18
var _json_stringify = JSON.stringify;
JSON.stringify = function(value) {
    var _array_tojson = Array.prototype.toJSON;
    delete Array.prototype.toJSON;
    var r=_json_stringify(value);
    Array.prototype.toJSON = _array_tojson;
    return r;
};

$.noConflict();

var settingsIcon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAABmJLR0QA/wD/AP+gvaeTAAAgAElEQVR4nO2de4wkx32Yv6p+znOfRx6PR/KOpHiSJdlWTEuIHSECDCQIAucF2EhsBTBiOfE/NpAA+TOAgSCBYThAkACxLTiO4Eh5CYmR+CXHkmA4smyLomUeSYtvkbzH3t0+5j39rsofPTM7O9uzt7M7s7e7V9+hMbPdPT09c/XN71fV1VVgMBgMBoPBYDAYDAaDwWAwGAwGg8FgMBgMBoPBYDAYDAaDwbBAxIM+gcPwqU/9nP1E/+YTmZBXrEw/CmJNCb0GYk3AKuAhdEVr4QqBL7QoAaB1WwkyAAEp0BGCjoY+WvfQYhshttBqG8EW2t4u6+zGZ1/8bP8BflzDKeJUCfITn/oJP+t7H1FafUwgvxf4IOgrwJOAfVLnIWBHa24KId7X8L5G3wBxU4jsPQE3w17r1hdf/WJ8UudjeHA8UEF+/BM/U5cq/qsafgj0p4APc4IiHAMFvKcRbwh4DfTrGvFGhvXGf3vhP9x40CdnmB8nLsg//PhnrmqsHwX9d9E8D1gnfQ4Lpge8IeANEK8j9CtaWdejq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v5P3EeQM1E4fvhX7L8ihPyy1vzCvT+Mf/FPv0DMrhzW2HNZsEyOuzopyHA/wzFZf5ry5R+0rlYuiqdKS+IpqySuWC5PWQ5PCXn4RoFFoDNuq5Q/jLv6K3e+mXz15f/JNvnsAWrwOFz29iQ/+VOdnR/+ldKTWivvt346epNiKabJMS6JEeQB8vgnWHn0o9ZT1UfEFbcqLluuWJO2fkTaYk1YrAuLdcHsadskWuktrcSNLOFmGvHtaIfrt1+N//yt32STXRkmH4fP9zXWnAlBCjisJEUjdxe1Ys1+04hh7lz4MNVHv9u+UFnVa1ZZrlgS2/J0XUgs6ci8Q5kizTLVFxKlY9FLY9ppoFpRW7Ru/L/0xtY7BBRf2xhfsonnw7/3cVYFGRbqoQhHTa8Ye73hbJFSfDcgTG+6nSbK1Br+2auk52j2f6hpTbvjlfTJ6DF8neHsMVlfGJdj+DjZfWRaBJnKWRUEdiUpKuDTBIHiKGI4exQJMi2CHJRmHchZFgT2XtSZFjkm52ofMi6MiSJnj3FBCu8G5GBBDtV74qwLAnsjyXAZdjERE88peJx8bjgbHEWQcVEOxXkQZMhkWB1GjcnuJUU9eY0gZ4+iFKlIkMkWrZmyhfNaMCabeGF6K5ZdsM5w+pkUZFoUOZIYQ857wSi6QGgEOR8cVpBj1S/PU4pVxPgXNK2Z16RYZ5NxQaa1Zh2b8y7IONO+OCPI2eRQzbTHxRQMI8hZZa6RwmAwGAwGg8FgMBgMBoPBYDAYDAaD4WHj/wO6BRxhRcjh3gAAAABJRU5ErkJggg==';
var defaultLangs = ['eo--eo', 'en--eo', 'eo--en'];
var langOptionsSelector = '#ElektiLingvon option';
var shownLangs = undefined;

var selectedLang = function(lang) {
    return Cookies.get('nlernuvortaro_lingvoparo');
};

var isShownLang = function(lang) {
    return shownLangs.indexOf(lang) != -1;
};

var loadLangs = function() {
    if (localStorage.filtermod_shownLangs === undefined) {
        shownLangs = defaultLangs;
        saveLangs();
    }
    else {
        try {
            shownLangs = JSON.parse(localStorage.filtermod_shownLangs);
        }
        catch(_) {
            shownLangs = defaultLangs;
        }
        if (!Array.isArray(shownLangs)) {
            shownLangs = defaultLangs;
        }
    }
    addLang(selectedLang());
};

var saveLangs = function() {
    localStorage.filtermod_shownLangs = JSON.stringify(shownLangs);
};

var addLang = function(lang) {
    if (lang === undefined || lang === null) {
        return;
    }
    if (!isShownLang(lang)) {
        shownLangs.push(lang);
    }
    saveLangs();
};

var removeLang = function(lang) {
    var index = shownLangs.indexOf(lang);
    if (index != -1) {
        shownLangs.splice(index, 1);
    }
    saveLangs();
};

loadLangs();

var settingsButton = jQuery('<img>')
    .attr('src', settingsIcon)
    .css({
        'width': '18px',
        'height': '18px',
        'float': 'right',
        'cursor': 'pointer'
    });

var exitButton = jQuery('<button>Eliri</button>')
    .css({
        'display': 'block',
        'margin-bottom': '0.25rem'
    });

var settings = jQuery('<div></div>')
    .css({
        'height': '15em',
        'overflow': 'auto',
        'margin-left': '0.25rem',
        'margin-top': '0.25rem'
    })
    .hide()
    .append(exitButton);

var vortaro = jQuery('body > *');

// Inject elements
jQuery('p').first().append(settingsButton);
jQuery('body').append(settings);

// Set up buttons
settingsButton.click(function() {
    vortaro.hide();
    settings.show();
});

exitButton.click(function() {
    settings.hide();
    vortaro.show();
});

// Inject settings page

var getLang = function(langdef) {
    var langs = langdef.split('--');
    if (langs[0] == 'eo') {
        return langs[1];
    }
    else {
        return langs[0];
    }
};

var skipArg = function(cb) {
    return function() {
        var args = jQuery(arguments).slice(1);
        return cb.apply(this, args);
    };
};

var optionToLang = function(option) {
    return getLang(option.value);
};

var isShownLangOption = function(option) {
    return isShownLang(optionToLang(option));
};

var availableOptions = jQuery(langOptionsSelector);

var refreshOptions = function() {
    jQuery('#ElektiLingvon').html('');
    availableOptions.each(function(_, option) {
        if (isShownLang(option.value)) {
            jQuery('#ElektiLingvon').append(option);
        }
    });
    jQuery('#ElektiLingvon').val(selectedLang());
};

refreshOptions();

availableOptions.each(function(_, el) {
    var label = jQuery('<label>'+jQuery(el).text()+'</label>');
    var checkbox = jQuery('<input type="checkbox">');
    
    if (isShownLang(el.value)) {
        checkbox.attr('checked', true);
    }
    
    if (selectedLang() == el.value) {
        checkbox.prop('disabled', true);
    }
    
    // Disable checkbox if its language is selected
    jQuery('#ElektiLingvon').change(function(event) {
        if (el.value == jQuery(event.target).val()) {
            checkbox.prop('disabled', true);
        }
        else {
            checkbox.prop('disabled', false);
        }
    });
    
    label.prepend(checkbox);
    settings
        .append(label)
        .append('<br>');
    
    // Add/Remove languages on click
    checkbox.click(function() {
        if (this.checked) {
            addLang(el.value);
        }
        else {
            removeLang(el.value);
        }
        refreshOptions();
    });
});