// ==UserScript==
// @name MrCong全量加載
// @namespace http://tampermonkey.net/
// @version 0.39
// @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
// @require https://cdn.staticfile.org/viewerjs/1.10.4/viewer.min.js
// ==/UserScript==
(async function () {
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;
}
//获取页数
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(`.titleHrefs,.postTagHrefs{
border: 1px solid;
border-radius: 4px;
margin-bottom:1px;
}
#title_info{
color: pink;
border:1px solid;
border-color:rgba(0,0,0,0);
border-bottom-color:pink;
}
#separate{
color:white;
}
#downHref>a{
color:pink;
border:1px solid;
border-color:rgba(0,0,0,0);
border-bottom-color:#815c94;
}
.titleHrefs>div,.postTagHrefs>div{
display:inline;
}
#spanitemdiv{
color:#FFFAF0;
}
#spanitem{
color:#FFFAF0;
}`);
let titleHrefs = $("<div class = titleHrefs></div>");
let postTagHrefs = $("<div class = postTagHrefs></div>");
await new Promise(function (resolve) {
$("#crumbs a").each(function (index, value) {
let hrefDiv = $("<div class = hrefDiv></div>")
let title = $(this).attr("id", "title_info");
hrefDiv.append(title)
titleHrefs.append(hrefDiv);
// console.log(title);
let p3 = $("<div id = separate>\xa0/\xa0</div>");
titleHrefs.append(p3);
});
$(".post-tag a").each(function (index, value) {
let hrefDiv = $("<div class = hrefDiv></div>")
let title = $(this).attr("id", "title_info");
hrefDiv.append(title)
postTagHrefs.append(hrefDiv);
// console.log(title);
let p3 = $("<div id = separate>\xa0/\xa0</div>");
postTagHrefs.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()
// console.log(inerBoxStr);
let imgSize = inerBoxStr.match(patt)[0];
console.log(imgSize);
let downHref;
let p3;
//let p3 =$("<b id = separate>\xa0/\xa0</b>")
$("p[style] a").each(function (index, value) {
downHref = $("<div id = downHref></div>");
let itemTitleHref = $("<a>图片下载</a>").attr("href", $(this)[0].href).text(`图片下载链接[ ${index+1} ]`);
downHref.append(itemTitleHref);
titleHrefs.append(downHref);
p3 = $("<div id = separate>\xa0/\xa0</div>");
downHref.after(p3);
})
//titleHrefs.append(p3)
p3 = $("<div id = separate>\xa0/\xa0</div>");
titleHrefs.append($("<div id = spanitem></div>").text(`解压密码: (${password})`))
p3 = $("<div id = separate>\xa0/\xa0</div>");
titleHrefs.append(p3);
titleHrefs.append($("<div id = spanitem></div>").text(`图片大小: (${imgSize})`))
p3 = $("<div id = separate>\xa0/\xa0</div>");
titleHrefs.append(p3);
let SpanItemDiv = $("<div id = spanitemdiv></div>")
let spanItem = $("span[itemprop]").text();
console.log(spanItem);
SpanItemDiv.append(spanItem);
titleHrefs.append(SpanItemDiv);
/*!
* 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;
}
body{
background:#4a4035;
font-family: -apple-system, BlinkMacSystemFont, Tahoma, Arial, "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
#viewer{
padding:0px;margin:0px
}
.imgbox{
position: relative;
overflow: hidden;
}
.imgnum{
position: absolute;
font-size:90%;
left: 5px;
top: 5px;
background: #17A1FF;
background: rgba(23,161,255,0.5);
z-index: 100;
padding: 0px 5px 1px 5px;
color: #f9f9f9;
color: rgba(249,249,249,1);
border-radius: 2px;
}`);
var os = function () {
var 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.isAndroid) //判断是否Android
{
addStyle(`
.imgnum{
font-family: fantasy,sans-serif;
}`);
}
'use strict';
$("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(titleHrefs);
do {
link = newStr + "-anh/" + i;
let data = await Get(link);
let image = $(".content img", data);
image.each(function (item) {
let imgli = $('<li class = "imgbox"></li>');
let imageItem = '<img width= "100%" style="float: left;border-radius: 8px; margin: 1px" src="' + $(this)[0].src + '" >';
//序号
let stringNum = "<div class = 'imgnum'>{imgnum}</div>";
let newStringNum = stringNum.replace('{imgnum}', ` `)
imgli = imgli.prepend($(newStringNum));
imgli = imgli.append(imageItem);
viewer2.append(imgli)
});
i = i + 1;
if (i === (length + 2)) {
$(document).ready(function () {
$("#viewer").after(postTagHrefs);
});
}
} while (i < length + 2);
setTimeout(() => {
let viewer3 = new Viewer(document.getElementById('viewer'), {
//inline:true,
viewed() {}
});
}, 3000);
// Your code here...
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();
});
function Get(link) {
return new Promise(function (resolve) {
$.get(link, data => {
resolve(data);
})
});
}
})();