Javbus 工具

Javbus 瀑布流排序

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 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
        });
    })





})();