您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
传统表格排序
当前为
// ==UserScript== // @name table-sorter // @namespace https://gf.qytechs.cn/ // @version 0.0.1 // @description 传统表格排序 // @author HqLin // @match https://tfgames.site/* // @grant GM.setClipboard // @grant GM.addStyle // @license AGPLv3 // ==/UserScript== 'use strict'; (function () { document.querySelectorAll('table').forEach((tbl) => { const thead = tbl.querySelector('thead') const theads = tbl.querySelectorAll('thead th') const trows = tbl.querySelectorAll('tbody tr') if (trows.length === 0 || theads.length === 0 || !thead) return theads.forEach((head, idx) => head.dataset.index = idx) let sortingIdx = 0, reverse = false thead.addEventListener('click', (ev) => { const header = ev.target.closest('th') reverse = header.dataset.index === sortingIdx ? !reverse : false sortingIdx = header.dataset.index const tbody = tbl.querySelector('tbody') tbody.innerHTML = '' const trowsSorted = Array.from(trows).sort((rowA, rowB) => { const cellA = rowA.querySelectorAll('td')[sortingIdx]?.textContent const cellB = rowB.querySelectorAll('td')[sortingIdx]?.textContent const delta = cellA - cellB return (reverse ? -1 : 1) * (Number.isNaN(delta) ? cellA.localeCompare(cellB) : delta) }) trowsSorted.forEach(row => tbody.appendChild(row)) }) }) })()
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址