javdb auto open

增加页面顶部底部按钮和一键下种按钮

ของเมื่อวันที่ 21-09-2023 ดู เวอร์ชันล่าสุด

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         javdb auto open
// @namespace    javdb enhancement
// @author   jimmly
// @version      0.3.3
// @description  增加页面顶部底部按钮和一键下种按钮
// @create         2023-9-21
// @include        *javdb*
// @grant         GM_getValue
// @grant         GM_setValue
// @grant         GM.getValue
// @grant         GM.setValue
// @require       https://openuserjs.org/src/libs/sizzle/GM_config.min.js
// @license MIT
// @run-at document-idle
// ==/UserScript==

/**
 * @typedef { import('jquery') } $
 * @typedef { import('jQuery') } jQuery
 */
(async withJQuery => {

    let conf = new GM_config({
        id: 'GM_config_javdb',
        title: 'Configurable Options Script',
        fields: {
            'asdf': {
                'label': 'Search keys',
                'type': 'textarea',
                'default': '萝莉;奴隶;奴隸;调教;調教;拘束;軟體;软体;痙;攣;拘;束;固定;sm;白虎,捆绑,捆綁;束縛;束缚,母狗;'
            },
        },
    })


    var addStyle = function (css) {
        var s = document.createElement('style');
        s.appendChild(document.createTextNode(css));
        document.getElementsByTagName('head')[0].appendChild(s);
    }
    addStyle(`
        a:link{color:green;}
        a:hover{color:red;}
        a:active{color:yellow;}
        a:visited{color:orange;}
        .btn1   {   
                    opacity:0.3;-moz-transition-duration:0.2s;-webkit-transition-duration:0.2s;
                    padding:1px;background:white;font-size: 10; text-align: center; vertical-align: middle;
                    border-radius:5px 5px 5px 5px;cursor:pointer; left:0px;z-index:9999;
                    background:white; 
                    width:40px;height:40px;line-height:40px;
                }
    `);
    // 创建超链接,不会被拦截
    function createSuperLabel(url, id) {
        if (!id)
            id = url;
        // 防止反复添加
        if (!document.getElementById(id) && !localStorage[id]) {
            let tmpLink = document.createElement("a");
            localStorage[id] = true
            tmpLink.setAttribute("href", url);
            tmpLink.setAttribute("target", "_blank");
            tmpLink.setAttribute("id", id);
            document.body.appendChild(tmpLink);
            tmpLink.click();
            return true
        }
        return false;
    }
    withJQuery(/**  @param { $ } $ */function ($, win) {
        //$('item a').removeAttr('style')
        new Promise((resolve, reject) => resolve(conf.get('asdf')))
            .then(conf => {
                console.log('config value of keys', conf)
                return (conf.toString()).split(/;|;|,|,/i)
            })
            .then(keys => {
                if (window.location.href.indexOf('tags') > -1)
                    $('.item a').each((i, element) => {
                        let el = $(element)
                        $.each(keys, (inex, key) => {
                            if (key && el.attr('title').toLowerCase().indexOf(key.toLowerCase()) > -1) {

                                console.log(key, createSuperLabel(el.prop('href')), el.prop('href'))

                                return false;
                            }
                        })

                    });
            })

        let container = $(document.createElement('div')).css({
            'cssText': `position:fixed;top:15%;width:40px;height:240px;left:0px;z-index:9999`
        });
        let topref = 80;
        //最顶按钮
        let toTopBtn = $(document.createElement('div')).text('Top');
        toTopBtn.click(function () {
            window.scrollTo(0, 0);
        });

        container.append(toTopBtn).append($('<br />'));
        if (window.location.href.indexOf("thread") == -1) {
            //下载按钮
            let downloadBtn = $(document.createElement('div')).text('Lod');
            downloadBtn.click(function () {
                let url = $(".t_attachlist > dt > a:eq(1)").prop('href');
                let filename = $("div.mainbox.viewthread>h1").text().trim() + '.torrent';
                console.log(filename)
                $.ajax({
                    url,
                    success: function (result, status, xhr) {
                        let alink = document.createElement('a');
                        alink.download = filename;
                        alink.href = $(result).find("#downloadBtn").prop('href');
                        document.body.appendChild(alink);
                        alink.click();
                    },
                    error: function (xhr, status, error) {
                        console.log(status, error)
                    }
                });
            });
            container.append(downloadBtn).append($('<br />'));

        }
        else {
            $('tr').hover(function () {
                // $(this).find('*').each(function (item) {
                //     $(this).data('oldcolor', $(this).css("background-color"))
                // })
                $(this).find('*').css("background-color", "#9AAAC7")
            },
                function () {
                    $(this).find('*').css("background-color", '');
                });
        }
        //最低按钮

        let toBottomBtn = $(document.createElement('div')).text('Bot');;

        toBottomBtn.click(function () {
            window.scrollTo(0, document.body.scrollHeight);
        });
        container.append(toBottomBtn).append($('<br />'));

        let fastBtn = $(document.createElement('div')).text('Set'),
            middleBtn = $(document.createElement('div')).text('Sta'),
            slowBtn = $(document.createElement('div')).text('Low');
        container.append(fastBtn).append($('<br />'))
            .append(middleBtn).append($('<br />'))
            .append(slowBtn).append($('<br />'))

        container.find('div')
            .addClass('btn1')
            .hover(
                function (item) {
                    $(this).css('opacity', 1).css('border', '1px solid black')
                }, function (item) {
                    $(this).css('opacity', 0.3).css('border', 'none')
                })


        win.__wait = 900
        win.__step = 100;

        fastBtn.click(function () {
            conf.open();
            // if (win.__wait > 5) {
            //     win.__wait = win.__wait / 1.5
            // } else {
            //     win.__wait = 5
            // }

        });
        slowBtn.click(function () { win.__wait *= 1.5 });
        win.___func = function () {
            win.______h = $(document).scrollTop() + win.__step;
            if (win.______h >= $(document).height() - $(window).height()) {
                clearTimeout(win.___t)
                // win.___t = setTimeout(win.___func, 30000)
            } else {
                $(document).scrollTop(win.______h);
                win.___t = setTimeout(win.___func, win.__wait)
            }
        };
        $(document).keydown(function (event) {
            let e = event || window.event;
            let k = e.keyCode || e.which;
            if (k === 16) {
                //  isCtrl = true;
                middleBtn.click()
            } else if (k === 38) {  //up
                event.stopPropagation()
                slowBtn.click()

            } else if (k === 40) {//down
                event.stopPropagation()
                //fastBtn.click()
            }
        })




        middleBtn.click(function () {
            if (!!!win.___t) {
                win.___func();
            } else {
                clearTimeout(win.___t)
                win.___t = 0
            }
        })

        container.appendTo('body');

        $(window).blur(function () {
            clearTimeout(win.___t)
            win.___t = 0
        }).focus(function () {
            win.___func();
        })


    })
})(function (callback, safe) {
    if (typeof jQuery == "undefined") {
        let script = document.createElement("script")
        script.type = "text/javascript"
        script.src = "https://code.jquery.com/jquery-3.6.1.min.js"
        if (safe) {
            let cb = document.createElement("script")
            cb.type = "text/javascript"
            cb.textContent = "jQuery.noConflict();(" + callback.toString() + ")(jQuery, window);"
            script.addEventListener("load", function () {
                document.head.appendChild(cb)
            })
        } else {
            let dollar = undefined
            if (typeof $ != "undefined") dollar = $
            script.addEventListener("load", function () {
                jQuery.noConflict()
                $ = dollar
                callback(jQuery, window)
            })
        }
        document.head.appendChild(script)
    } else {
        setTimeout(function () {
            //Firefox supports
            callback(jQuery, typeof unsafeWindow === "undefined" ? window : unsafeWindow)
        }, 30)
    }
});