Zimuku Sort

字幕库按下载量排序

目前为 2023-02-26 提交的版本。查看 最新版本

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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址