All tables sortable

Make all tables on any page sortable by converting them to dataTables

< Отзив за All tables sortable

Отзив: Отлично - скриптът работи

§
Публикуван на: 23.05.2025

Very useful. Thank you!

additional button for only converting table containing selected text: ( the modified full script that also works with CORS here )

function ConvertTableFromSelection() {
    const selection = window.getSelection();
    let node;
    if (selection?.anchorNode?.nodeType === 1) {
        node = selection?.anchorNode;
    } else {
        node = selection?.anchorNode?.parentElement;
    }

    const table = node?.closest("table");
    if (table) {
        addDatatablesCSS();
        try {
            ConvertTable_ToDataTable(table);
        } catch (e) {
            console.error("[All tables sortable] selected table error:", e, table);
        }
    } else {
        alert("No table found near selected text.");
    }
}

GM_registerMenuCommand("Convert table containing selected text", () => {
    ConvertTableFromSelection();
});

You can use my changes freely if you want to.

Публикувайте отговор

Влезте, за да публикувате отговор.