Javbus 工具

Javbus 瀑布流排序

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name        Javbus 工具
// @description  Javbus 瀑布流排序
// @namespace    https://github.com/LiHang941/srcript/
// @version      0.05
// @author       lihang1329
// @include      https://www.javbus.com/*
// @supportURL https://github.com/LiHang941/srcript
// @grant        none
// @license MIT
// ==/UserScript==

(function () {
    let datas = Array.from($("div#waterfall div.item"));
    if(datas.length === 0){
        return
    }
    $("#waterfall").html('')
    let pages = $(".pagination a")
    let pageUrls = Array.from(pages).map(it => {
        let url = $(it).prop('href')
        let val = $(it).html()
        if (/\d+/.test(val)) {
            return {
                url: url,
                page:parseInt(val),
            }
        }
        return null
    }).filter(it => it != null)

    Promise.all(pageUrls.map(it => {
        let url = it.url
        let page = it.page
        const fetchwithcookie = fetch(url, { credentials: 'same-origin' });
        return fetchwithcookie.then(response => response.text())
            .then(html => new DOMParser().parseFromString(html, 'text/html'))
            .then(doc => {
                console.log(doc)
                let elems = $(doc).find("div#waterfall div.item");
                return {
                    elems,
                    url,
                    page
                };
            });

    })).then(arrs => {
        for (const arr of arrs) {
            for (const it of Array.from(arr.elems)) {
                datas.push(it)
            }
        }

    }).then(() => {
        window.datas = datas;
        datas = Array.from(datas).sort((a, b) => {
            let dateA = $($(a).find("date")[1]).html()
            let dateB = $($(b).find("date")[1]).html()
            return new Date(dateB).getTime() - new Date(dateA).getTime()
        })

        $("#waterfall").html(datas)
        $('.movie-box').css("height", "500px");
        $('#waterfall').masonry({
            itemSelector: ".item",
            isAnimated: false,
            isFitWidth: true
        });
    })





})();