字幕库按下载量排序
当前为
// ==UserScript==
// @name Zimuku Sort
// @namespace Violentmonkey Scripts
// @match https://zimuku.org/subs/*
// @grant none
// @version 0.1.2
// @author Ifover
// @license MIT License
// @description 字幕库按下载量排序
// ==/UserScript==
(function () {
let tbody = $('.table tbody')
let hTr = tbody.children()
let trArr = Array.from(hTr)
let sortNumArr = []
for (let tr of trArr) {
let tds = $(tr).children()
if (tds.length) {
let num = $(tds[3]).text()
num = num.indexOf('万') !== -1 ? parseFloat(num) * 10000 : parseInt(num)
sortNumArr.push(num)
}
}
// console.log(sortNumArr)
for (let i = 0; i < sortNumArr.length; i++) {
for (let j = 0; j < i; j++) {
if (sortNumArr[i] > sortNumArr[j]) {
let temp = sortNumArr[i];
sortNumArr[i] = sortNumArr[j];
sortNumArr[j] = temp
let temp2 = trArr[i];
trArr[i] = trArr[j];
trArr[j] = temp2;
}
}
}
// console.log(sortNumArr)
hTr.remove()
for (let tr of trArr) {
tbody.append(tr)
}
})();