24fa全量图片加載

24fa网页美女页面图片加载,啦啦啦

As of 2022-07-22. See the latest version.

// ==UserScript==
// @name         24fa全量图片加載
// @namespace    http://tampermonkey.net/
// @version      1.4
// @description  24fa网页美女页面图片加载,啦啦啦
// @author       LARA_SSR
// @exclude      https://www.24faw.com/c49.aspx
// @exclude      https://www.112w.cc/c49.aspx
// @include      /https?\:\/\/(www\.)?[0-9]*(w|faw)\.cc\/(m)?n[0-9]*c(49|71)/
// @license      MIT
// @grant        none
// @require      https://cdn.staticfile.org/jquery/3.6.0/jquery.min.js
// @require      https://cdn.staticfile.org/viewerjs/1.10.4/viewer.min.js
// ==/UserScript==


console.clear();
(function () {
    let id = setInterval(async function () {
        if (Fancybox4) {
            //打印开关
            isDebug = false;
            log("Fancybox4 --- isActive!\n");
            clearInterval(id);
            if (os.isAndroid || os.isPhone) //判断是否Android或Phone
            {
                $('script').empty();
                addStyle(fancyBoxCss);
                let open = 'Default';
                switch (open) {
                    case 'Fullscreen':
                        addStyle(fancyBoxCssAdditon);
                        addScript(fancyboxFullJs);
                        break;
                    case 'Default':
                        addStyle(`a[data-fancybox] img{cursor:zoom-in;}`);
                        addScript(fancyboxDefaultJs);
                        break;
                };

                // 标题
                let script2 = $('<script type="text/javascript">let pager=null;</script>');
                $("head").append(script2);
                addStyle('#titleHrefs{display: inline-block;background-color: #f9f4dc;border: 1px solid; border-radius: 4px;}');
                let titleHrefs = $("<div id =titleHrefs></div>");

                if (os.isPc) //判断是否PC
                {
                    if ($(".title2").length <= 0) {
                        titleHrefs.append($("header h1").text());
                        console.log("header h1 属性存在");
                    } else {
                        titleHrefs.append($(".title2").text());
                        console.log(".title2 属性存在");
                    }
                    console.log("PC");
                } else if (os.isPhone) //判断是否iPhone
                {
                    if ($(".title2").length <= 0) {
                        titleHrefs.append($("header h1").text());
                        console.log("header h1 属性存在");
                    } else {
                        titleHrefs.append($(".title2").text());
                        console.log(".title2 属性存在");
                    }
                    console.log("iPhone");
                } else if (os.isAndroid) //判断是否Android
                {
                    if ($(".title2").length <= 0) {
                        titleHrefs.append($("header h1").text());
                        console.log("header h1 属性存在");
                    } else {
                        titleHrefs.append($(".title2").text());
                        console.log(".title2 属性存在");
                    }
                    console.log("Android");
                } else if (os.isTablet) //判断是否平板
                {
                    if ($(".title2").length <= 0) {
                        titleHrefs.append($("header h1").text());
                        console.log("header h1 属性存在");
                    } else {
                        titleHrefs.append($(".title2").text());
                        console.log(".title2 属性存在");
                    }
                    console.log("Tablet");
                }

                //获取页数
                let paginationClass = $(".pager a");
                let myLength = paginationClass.length;
                // console.log(paginationClass);
                // console.log(myLength);
                // console.log($(paginationClass).eq(-2).text());


                /*!
                 * Viewer.js v1.10.4
                 * https://fengyuanchen.github.io/viewerjs
                 *
                 * Copyright 2015-present Chen Fengyuan
                 * Released under the MIT license
                 *
                 * Date: 2022-02-13T08:39:57.620Z
                 *viewerjsCSS*/
                let viewerCssLink = "https://cdn.staticfile.org/viewerjs/1.10.4/viewer.min.css";
                let viewerCssData = await Get(viewerCssLink);
                addStyle(viewerCssData);

                addStyle(`ul li{
                list-style-type:none;
                line-height:100%;
            }
            body{
                background:#4a4035;
            }
            #viewer{
                padding:0px;
                margin:0px;
            }
            .imgbox{
                position: relative;
                overflow: hidden;
            }
            .imgnum{
                position: absolute;
                font-size:75%;
                left: 5px;
                top: 5px;
                background: #17A1FF;
                background: rgba(23,161,255,0.5);
                z-index: 100;
                padding: 0px 5px;
                color: #f9f9f9;
                border-radius: 2px;
            }
        `);
                'use strict';
                $("body").empty();
                let i = 1;
                let num = 0;
                let str3 = self.location.href;
                let newStr = str3.replace(/.aspx/g, "");
                let flag = /c49(p)?\d*/g.test(newStr);
                if (flag) {
                    newStr = newStr.replace(/c49(p)?\d*/g, "");
                } else {
                    newStr = newStr.replace(/c71(p)?\d*/g, "");
                }
                // console.log(newStr);
                // console.log(self.location.href);

                let viewer2 = $('<ul id ="viewer"></ul>');
                $("body").append(viewer2)
                viewer2.append(titleHrefs);

                let n = 0;
                do {
                    let url2 = "";
                    if (flag) {
                        url2 = newStr + 'c49p' + i + ".aspx";
                    } else {
                        url2 = newStr + 'c71p' + i + ".aspx";
                    }
                    console.log(url2)
                    let data = await Get(url2);

                    let image;
                    if (str3.indexOf("www") > 0) {
                        image = $("#content img", data);
                    } else {
                        image = $("#content img", data);
                    }
                    image.each(function (item) {
                        n++;
                        let imgli = $('<li class = "imgbox"></li>');
                        if ($(this)[0].hasAttribute("src")) {
                            $(this).attr("data-original", $(this).attr("src"));
                        } else {
                            $(this).attr("src", $(this).attr("data-original"));
                        }
                        let src = $(this).attr("src");
                        $(this).attr("width", "100%");
                        $(this).attr("style", "float: left;border-radius: 8px; margin: 1px");
                        let imageItem = "<a data-fancybox=\'images\' href=\'" + src + "\'>" + $(this)[0].outerHTML + "</img></a>";
                        let stringNum = "<div class = 'imgnum'>{imgnum}</div>";
                        let newStringNum = stringNum.replace('{imgnum}', `${n}`)
                        imgli = imgli.prepend($(newStringNum));

                        imgli = imgli.append(imageItem);
                        viewer2.append(imgli)
                    });
                    i = i + 1
                    // setInterval(function () {
                    //     console.log('sleep');
                    // }, 1000);
                } while (i <= myLength);

                num = $("img").length
                $(".imgnum").each(function (index, value) {
                    if (index < num) {
                        // console.log($(this));
                        $(this).text(`[${index+1}/${num}]`)
                    } else {
                        return false;
                    }
                })

                // setTimeout(() => {
                //     let viewer3 = new Viewer(document.getElementById('viewer'), {
                //         //inline:true,
                //         viewed() {}
                //     });
                // }, 3000);

                function Get(link) {
                    return new Promise(function (resolve) {
                        $.get(link, data => {
                            resolve(data);
                        })
                    });
                }
            }
        }
    }, 100);


})();