All tables sortable

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

< 脚本All tables sortable的反馈

评价:好评 - 脚本运行良好

§
发布于:2025-05-23

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.

发表回复

登录以发表回复。