MrCong全量加載

mrCong全量加載,啦啦啦

31.07.2022 itibariyledir. En son verisyonu görün.

// ==UserScript==
// @name         MrCong全量加載
// @namespace    http://tampermonkey.net/
// @version      1.8
// @description  mrCong全量加載,啦啦啦
// @author       LARA_SSR
// @match        https://mrcong.com/*/
// @exclude      https://mrcong.com/tag/*
// @exclude      https://mrcong.com/category/*
// @exclude      https://mrcong.com/sets/*
// @exclude      https://mrcong.com/top*/*
// @exclude      https://mrcong.com/tim-kiem/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @license      MIT
// @require      https://cdn.staticfile.org/jquery/3.6.0/jquery.min.js
// ==/UserScript==

console.clear();

(function () {
  "use strict";
  let id = setInterval(async function () {
    if (Fancybox4) {
      //打印开关
      debugger;
      isDebug = false;
      log("Fancybox4 --- isActive!\n");
      clearInterval(id);
      if (os.isAndroid || os.isPhone) {
        //判断是否Android或Phone
        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 paginationClass = "div .page-link";
        let length = 0;
        let paginationExist = false;
        $(paginationClass).each(function () {
          if (paginationExist == true) {
            return false;
          }
          length = $(this).find("a").length;
          paginationExist = true;
          //console.log(linkArr);
          console.log("页数:" + length);
        });

        //标题
        addStyle(
          `.postTagHrefs{padding-bottom:10px}.postTagHrefs,.titleHrefs{color:#fffaf0;word-break:break-all}#title_info{color:pink;border:1px solid transparent;border-bottom-color:pink}#separate{color:#fff}#downHref>a{color:pink;border:1px solid transparent;border-bottom-color:#815c94}.postTagHrefs>div,.titleHrefs>div{display:inline-block}#spanitem,#spanitemdiv{color:#fffaf0}`
        );
        let header = $("<div class = titleHrefs></div>");
        let footer = $("<div class = postTagHrefs></div>");

        await new Promise(function (resolve) {
          $("#crumbs a").each(function () {
            let title = $(this).attr("id", "title_info");
            header.append(title);
            let p3 = $("<div id = separate>\xa0/\xa0</div>");
            header.append(p3);
          });
          $(".post-tag a").each(function () {
            let hrefDiv = $("<div class = hrefDiv></div>");
            let title = $(this).attr("id", "title_info");
            hrefDiv.append(title);
            footer.append(hrefDiv);
            let p3 = $("<div id = separate>\xa0/\xa0</div>");
            footer.append(p3);
          });
          resolve();
        });

        let password = $("strong+input[value]").attr("value");
        console.log("Password: " + password);

        let patt = /(?<=Dung lượng: )(\d+|([1-9]\d*\.?\d+))[A-Za-z]*(B|b)/g;
        let inerBoxStr = $(".box-inner-block").text();
        let imgSize = inerBoxStr.match(patt)[0];
        console.log(imgSize);
        let p3;
        $("p[style] a").each(function (index, value) {
          let download = $("<a>图片下载</a>")
            .attr("href", $(this)[0].href)
            .text(`图片下载链接[ ${index + 1} ]`);
          download.css({
            color: "pink",
            border: "1px solid transparent",
            "border-bottom-color": "#815c94"
          });
          header.append(download);
          p3 = $("<div id = separate>\xa0/\xa0</div>");
          download.after(p3);
        });
        let spanItem = $("span[itemprop]").text();
        let divTR = `解压密码:(${password})<div id = separate>\xa0/\xa0</div>图片大小:(${imgSize})<div id = separate>\xa0/\xa0</div>${spanItem}`;

        header.append(divTR);

        /* font-family: -apple-system,BlinkMacSystemFont,Tahoma,Arial,"Hiragino Sans GB","Microsoft YaHei",sans-serif; */
        addStyle(
          `ul li{list-style-type:none}body{display:block;margin:8px;background:#4a4035;font-family:fantasy,sans-serif}#viewer{margin:0;padding:0}.imgbox{position:relative;overflow:hidden;box-sizing:border-box;width:100%}.imgnum{position:absolute;top:6px;left:6px;z-index:100;padding:0 6px;border-radius:2px;background:#17a1ff;background:rgba(23,161,255,.5);color:#f9f9f9}.imgs{float:left;width:100%}`
        );

        //remove ad
        setInterval(function () {
          $("#viewer").prevAll().remove();
          $("#Autopage_number").remove();
        }, 100);

        $("body").empty();
        let i = 1;
        let str3 = self.location.href;
        let newStr = str3.replace(/-anh.+/g, "");
        let link = "";
        let viewer2 = $('<ul id ="viewer"></ul>');
        $("body").append(viewer2);
        viewer2.append(header);
        let n = 0;
        do {
          link = newStr + "-anh/" + i;
          let data = await Get(link);

          let image = $(".content img", data);
          image.each(function (index, item) {
            n++;
            let imgli = $('<li class = "imgbox"></li>');
            let imageItem =
              '<a data-fancybox="images" href="' +
              $(this)[0].src +
              '"><img class="imgs" src="' +
              $(this)[0].src +
              '" ></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;
          if (i === length + 2) {
            $(document).ready(function () {
              $("#viewer").after(footer);
            });
          }
        } while (i < length + 2);

        let imgCount = $("#viewer img").length;
        console.log("imgCount: " + imgCount);

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

        //删除标题最后一个"/"
        $(document).ready(function () {
          // $(".titleHrefs div").eq(-1).remove();
          $(".postTagHrefs #separate").eq(-1).remove();
        });
      }
    }
  }, 100);
})();