Greasy Fork

Greasy Fork is available in English.

ヤフオクの入札件数順表示を更に終了時刻順番で並び替え

ヤフオクの検索結果が入札件数順で表示されている時に、その内容を更に終了時刻順番で並び替える

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         ヤフオクの入札件数順表示を更に終了時刻順番で並び替え
// @namespace    https://hisaruki.ml/
// @version      2
// @description  ヤフオクの検索結果が入札件数順で表示されている時に、その内容を更に終了時刻順番で並び替える
// @author       hisaruki
// @match        https://auctions.yahoo.co.jp/*
// @icon         https://www.google.com/s2/favicons?domain=yahoo.co.jp
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
    const Append = function(products){
        $("ul.Products__items").css("filter", "grayscale(1)");
        if(products.filter(x => ($(x).find(".Product__bid").text() - 0) == 0).length == 0){
            let a = $(".Pager__list a").eq(0);
            let href = a.attr("href");
            a.remove();
            console.log(href);
            fetch(href)
                .then(response => response.text())
                .then(function (html) {
                    $(html).find(".Product").each(function(){
                        $("ul.Products__items").append($(this));
                    });
                    Append(Array.from($(html).find("ul.Products__items li.Product")));
                });
        }else{
            Sort();
        }
    }

    const Sort = function(){
        let root = $("ul.Products__items");
        let products = [];
        root.find("li.Product").each(function(){
            products.push($(this).clone());
            $(this).remove();
        });
        products.filter(x => {
            return (x.find(".Product__bid").text() - 0) > 0;
        })
        .sort((a, b) => {
            a = a.find("[data-auction-endtime]").attr("data-auction-endtime") - 0;
            b = b.find("[data-auction-endtime]").attr("data-auction-endtime") - 0;
            return a - b;
        }).map(x => {
            root.append(x);
            return true;
        });
        products.filter(x => {
            return (x.find(".Product__bid").text() - 0) == 0;
        }).map(x => {
            root.append(x);
            return true;
        });
        $("ul.Products__items").css("filter", "grayscale(0)");
    }

    let u = new URLSearchParams(document.URL);
    if(u.get("s1") == "bids" && u.get("o1") == "a"){
        Append(Array.from($("ul.Products__items li.Product")));
    }

    // Your code here...
})();