24fa全量图片加載

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

As of 2022-03-24. See the latest version.

// ==UserScript==
// @name         24fa全量图片加載
// @namespace    http://tampermonkey.net/
// @version      0.62
// @description  24fa网页美女页面图片加载,啦啦啦
// @author       LARA_SSR
// @exclude      https://www.24faw.com/c49.aspx
// @exclude      https://www.112w.cc/c49.aspx
// @include      /^((https|http|ftp|rtsp|mms)?:\/\/)[A-Za-z]{3}\.[0-9]*(w|faw)\.cc\/(m)?n[0-9]*c(49|71)\.aspx$/
// @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==

(async function () {
    $('script').empty();

    let script2 = $('<script type="text/javascript">let pager=null;</script>');
    $("head").append(script2)
    let addStyle = function (aCss) {
        let head = document.getElementsByTagName('head')[0];
        if (head) {
            let style = document.createElement('style');
            style.setAttribute('type', 'text/css');
            style.textContent = aCss;
            head.appendChild(style);
            return style;
        }
        return null;
    }

    // 标题
    addStyle('#titleHrefs{display: inline-block;background-color: #f9f4dc;border: 1px solid; border-radius: 4px;}');
    let titleHrefs = $("<div id =titleHrefs></div>");

    let os = function () {
        let ua = navigator.userAgent, //获取浏览器UA
            isWindowsPhone = /(?:Windows Phone)/.test(ua),
            isSymbian = /(?:SymbianOS)/.test(ua) || isWindowsPhone,
            isAndroid = /(?:Android)/.test(ua),
            isFireFox = /(?:Firefox)/.test(ua),
            isChrome = /(?:Chrome|CriOS)/.test(ua),
            isTablet = /(?:iPad|PlayBook)/.test(ua) || (isAndroid && !/(?:Mobile)/.test(ua)) || (isFireFox && /(?:Tablet)/.test(ua)),
            isPhone = /(?:iPhone)/.test(ua) && !isTablet,
            isPc = !isPhone && !isAndroid && !isSymbian;
        return {
            isTablet: isTablet,
            isPhone: isPhone,
            isAndroid: isAndroid,
            isPc: isPc
        };
    }();
    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 {
        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"));
            }
            $(this).attr("width", "100%");
            $(this).attr("style", "float: left;border-radius: 8px; margin: 1px");
            let imageItem = $(this)[0].outerHTML + '</img>';

            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);
            })
        });
    }
})();