tablefilter

Adds filter dropdowns to the top row of any .table

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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);
        }
    }
})();