tablefilter

Adds filter dropdowns to the top row of any .table

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

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

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         tablefilter
// @namespace    crinfarr.io
// @version      2024-07-12
// @description  Adds filter dropdowns to the top row of any .table
// @author       Crinfarr
// @match        *://*/*
// @grant        none
// @run-at       context-menu
// ==/UserScript==

(function() {
    for (let table of document.getElementsByClassName("table")) {
        let headers = table.getElementsByTagName('thead')[0].children[0].children;
        for (let headeridx in headers) {
            let ipt = document.createElement('input');
            ipt.type = 'text';
            ipt.addEventListener("change", () => {
                for (let row of table.getElementsByTagName('tbody')[0].children) {
                    if (ipt.value == '') {
                        row.hidden = false;
                    }
                    let cell = row.children[headeridx]
                    let filters = ipt.value.split(/(?!<\\)\|\|/gm).map(s => s.trim());
                    if (filters.some((filter) => {
                        return cell.innerText.includes(filter);
                    })) {
                        console.log(`${cell.innerText} contains ${filters}`);
                        row.hidden = false;
                    } else {
                        console.log(`${cell.innerText} does not contain ${filters}`);
                        row.hidden = true;
                    }
                }
            });
            headers[headeridx].appendChild(ipt);
        }
    }
})();