// ==UserScript==
// @name 手机看图、小说适配
// @namespace http://tampermonkey.net/
// @version 9.500.9.91
// @description 自动滚动,图片集合,页面旋转,字体放大,去除浮动广告
// @author You
// @match *://*/*
// @require https://cdn.bootcss.com/jquery/3.7.1/jquery.min.js
// @run-at document-body
// @grant GM_setValue
// @grant GM_getValue
// @license MIT
// ==/UserScript==
this.$ = this.jQuery = jQuery.noConflict(true);
(function($) {
'use strict';
if (document.querySelector('.JqMA-btn-all') ||
$(".JqMA-btn-all", window.parent.document).length) {
return;
}
function dqSlt(selectPath) {
return $(document.querySelectorAll(selectPath)).add($(document.querySelectorAll('iframe')).contents().find(selectPath));
}
function addCss(dom1, style1) {
var id1 = "JqMA-" + Math.random().toString(36).replace(".", "") +
Math.random().toString(36).replace(".", "");
$(document.querySelector("head")).append($("<style>").attr({
id: id1
}).html(`html body ${dom1}{${style1}}`));
return id1;
}
function removeCss(id1) {
if (id1) {
$(document.querySelectorAll("#" + id1)).remove();
}
}
function uniqueArr(arr) {
for (var i = 0; i < arr.length; i++) {
for (var j = i + 1; j < arr.length; j++) {
if (JSON.stringify(arr[i]) == JSON.stringify(arr[j])) { //第一个等同于第二个,splice方法删除第二个
arr.splice(j, 1);
j--;
}
}
}
return arr;
}
var DSImg = 1;
var winWidth = parseInt(dqSlt("html").width()),
winProp = window.innerHeight / window.innerWidth,
winHeight = parseInt(winWidth * winProp);
if (winHeight < 400 || winWidth < 200) {
winWidth = 393;
winHeight = 767;
winProp = 767 / 393;
}
var winW = winWidth > winHeight ? winHeight * 0.6 : winWidth;
var wHeight = winW * 0.1,
SPicH = winWidth * 0.12,
top = (winHeight - wHeight) * 0.5;
var html_style =
`html,body {
overflow-wrap: break-word !important;
scroll-behavior: auto !important;
filter: none !important;
min-height: ${winHeight}px !important;
}`;
var inner_style =
`.JqMA-inner-all{
position: relative !important;
z-index: 2147483646 !important;
margin: 0 !important;
border: 0 !important;
padding: 0 !important;
width: 100% !important;
display: block !important;
overflow-wrap: break-word !important;
}
.JqMA-inner-html {
height: auto !important;
}
.JqMA-inner-pic,
.JqMA-inner-word {
margin: ${0.2 * winHeight}px 0 ${0.2 * winHeight}px 0 !important;
background: black !important;
}
.JqMA-inner-pic {
height: auto !important;
text-align: left !important;
font: 0 "Fira Sans", sans-serif !important;
}
.JqMA-inner-pic,
.JqMA-inner-pic *:not(.JqMA-mark-pageNext) {
box-sizing: border-box !important;
border-radius: 0 !important;
float: none !important;
opacity: 1 !important;
visibility: visible !important;
filter: none !important;
}
.JqMA-inner-pic *{
overflow-wrap: break-word !important;
margin: 0 !important;
padding: 0 !important;
position: static !important;
}
.JqMA-inner-pic *:not(a){
border: 0 !important;
}
.JqMA-inner-pic *::before,
.JqMA-inner-pic *::after {
display: none !important;
}
.JqMA-inner-pic picture,
.JqMA-inner-pic img {
display: inline-block !important;
width: 100% !important;
height: auto !important;
user-select: none !important;
object-fit: contain !important;
background: gray !important;
}
.JqMA-inner-pic xmp,
.JqMA-inner-pic a {
color: #F2F2F2 !important;
background: black !important;
vertical-align: top !important;
height: ${SPicH}px !important;
overflow: hidden !important;
font-size: ${winW * 0.05}px !important;
cursor: pointer !important;
}
.JqMA-inner-pic a:visited {
color: #741274 !important;
}
.JqMA-inner-pic xmp {
display: none !important;
white-space: pre-wrap !important;
white-space: -moz-pre-wrap !important;
white-space: -pre-wrap !important;
white-space: -o-pre-wrap !important;
word-wrap: break-word !important;
text-align: inherit !important;
line-height: 1.3 !important;
width: 76% !important;
}
.JqMA-inner-pic a{
display: inline-block !important;
user-select: none !important;
line-height: normal !important;
width: 12% !important;
text-align: center !important;
text-decoration: none !important;
border: 1px solid red !important;
}
.JqMA-btn-all,
.JqMA-inner-all,
.JqMA-inner-pic * {
min-width: none !important;
max-width: none !important;
min-height: none !important;
max-height: none !important;
}
.JqMA-btn-all {
color: white !important;
display: block !important;
background:black !important;
text-align: center !important;
line-height: 2.8 !important;
border-radius: 0 !important;
cursor: pointer !important;
user-select: none !important;
z-index: 999999999999 !important;
padding: 0 !important;
border: 0 !important;
font-weight: bold !important;
filter: none !important;
position: fixed !important;
font-size: ${winW * 0.036}px !important;
height: ${wHeight}px !important;
width: ${wHeight}px !important;
}
`;
var css_style =
`.JqMA-css-blank {
margin-top: ${1.5 * winHeight}px !important;
}
.JqMA-mark-pageNext,
.pagetual_pageBar {
display: block !important;
height: 0 !important;
min-height: none !important;
margin: 0 !important;
border: 0 !important;
padding: 0 !important;
overflow: hidden !important;
}
.JqMA-css-textBig,.JqMA-inner-word {
text-align: left !important;
text-indent: 2em !important;
letter-spacing: normal !important;
line-height: normal !important;
filter: none !important;
overflow-wrap: break-word !important;
}
.JqMA-css-textBig:not(a,a *),.JqMA-inner-word {
color: #F2F2F2 !important;
background-color: black !important;
}
.JqMA-css-colorG{
color: green !important;
}
.JqMA-css-yScroll{
overflow-y: scroll!important;
}
.JqMA-css-xScroll{
overflow-x: scroll!important;
}
.JqMA-css-hide_fix,.JqMA-css-hide_btn,
.JqMA-inner-hide_slt,.JqMA-css-hide_br {
display: none !important;
top: 0 !important;
}
.JqMA-css-fixed {
position: fixed !important;
}
.JqMA-inner-pic .JqMA-css-smallPic {
width: 12% !important;
height: ${SPicH}px !important;
}
.JqMA-css-transform,.JqMA-css-rotate {
max-height: none !important;
height: auto !important;
padding-bottom: ${1.5 * winHeight}px !important;
}
.JqMA-css-transform {
transform: translate(0%, 0%) !important;
}
.JqMA-css-rotate {
float: right !important;
position: relative !important;
left: -100% !important;
transform: rotateZ(-90deg) !important;
transform-origin: 100% 0 !important;
-webkit-transform: rotateZ(-90deg) !important;
-webkit-transform-origin: 100% 0 !important;
-moz-transform: rotateZ(-90deg) !important;
-moz-transform-origin: 100% 0 !important;
width: ${winHeight}px !important;
min-width: none !important;
max-width: none !important;
}`;
var jianG = wHeight;
var left = 0,
left2 = wHeight + left,
left3 = wHeight + left2;
var leftCss = "left:" + left + "px;",
leftCss2 = "left:" + left2 + "px;",
leftCss3 = "left:" + left3 + "px;";
var animateTime = 800,
scrollNum = parseInt(winHeight * 5.2 * animateTime / 100000);
var scrollJu = 4;
var picwh = 50;
function addInput(class1, value1, style1) {
$(document.querySelector("html")).append($('<div>').attr({
class: "JqMA-btn-all " + class1,
style: style1 + "px;"
}).html(value1));
}
addInput('JqMA-btn-del', 'X', leftCss + "top:" + (top));
addInput('JqMA-btn-width', 'W', leftCss + "top:" + (top - 1 * jianG));
addInput('JqMA-btn-pic', 'P', leftCss + "top:" + (top - 2 * jianG));
addInput('JqMA-btn-down', '▽', leftCss + "top:" + (top - 3 * jianG));
addInput('JqMA-btn-up', '△', leftCss + "top:" + (top - 4 * jianG));
addInput('JqMA-btn-scrollDiv', "O", leftCss + "top:" + (top - 5 * jianG));
addInput('JqMA-btn-search', "S", leftCss + "top:" + (top - 6 * jianG));
addInput('JqMA-btn-transform', "T", leftCss + "top:" + (top + jianG));
addInput('JqMA-btn-jia', '+', leftCss + "top:" + (top + 2 * jianG));
addInput('JqMA-btn-jian', '-', leftCss + "top:" + (top + 3 * jianG));
addInput('JqMA-btn-next', "N", leftCss + "top:" + (top + 4 * jianG));
addInput('JqMA-btn-picwh', picwh, leftCss + "top:" + (top + 5 * jianG));
addInput('JqMA-btn-Ju', scrollJu, leftCss2 + "top:" + (top));
function addInner() {
if (!dqSlt(".JqMA-inner-html").length) {
$(document.querySelector("body")).prepend($("<div>").attr({
class: "JqMA-mark-pageNext"
})).prepend($("<div>").attr({
class: "JqMA-inner-html JqMA-inner-all"
}));
}
$(document.querySelector("head:not(.JqMA-mark-addStyle)")).append(
$("<style>").html(html_style + inner_style + css_style)
).addClass("JqMA-mark-addStyle");
dqSlt("head:not(.JqMA-mark-addStyle)").append(
$("<style>").html(css_style)
).addClass("JqMA-mark-addStyle");
}
setTimeout(function() {
dqSlt("body").filter(function() {
return $(this).css("overflow-y") == "hidden";
}).addClass("JqMA-css-yScroll");
firstRun();
var ifrNum_1 = 0;
setInterval(function() {
var ifrNum_2 = dqSlt("*").length;
if (ifrNum_1 < ifrNum_2) {
ifrNum_1 = ifrNum_2;
firstRun();
}
}, 2 * 1000);
delHide();
}, 10);
function firstRun() {
addInner();
if (widthN > 12) {
fontInterFn();
}
if (picZ) {
imgInterFn()
}
if (Dtransform == 1) {
dqSlt(":not(.JqMA-css-hide_fix,head *,.JqMA-btn-all,#pagetual-picker)").filter(function() {
return /sticky|fixed/.test($(this).css("position"));
}).addClass("JqMA-css-hide_fix JqMA-css-fixed");
} else if (Dtransform == 2) {
dqSlt(":not(.JqMA-css-fixed,head *,.JqMA-btn-all,#pagetual-picker)").filter(function() {
return /sticky/.test($(this).css("position"));
}).addClass("JqMA-css-fixed");
}
dqSlt("html").off("click.clickScroll").on('click.clickScroll', function(event) {
var _target = $(event.target);
if (_target.is("a,a *")) {
return;
}
var direction = 1;
if (scrollJu < 0) {
direction = -1;
}
if (_target.has(".JqMA-css-textBig").length || _target.is(".JqMA-css-textBig,.JqMA-css-textBig *")) {
autoScrollBy(direction * 0.94 * (Drotate ? winWidth : winHeight));
} else if (_target.has("img,picture").length || _target.is("img,.JqMA-inner-pic *")) {
if (_target.is("img:not(.JqMA-inner-pic *)") &&
_target.outerWidth() < 0.2 * winWidth) {
return;
}
autoScrollBy(direction * 0.4 * (Drotate ? winWidth : winHeight));
}
});
dqSlt("html").off("touchstart.stopPause").on("touchstart.stopPause", ":not(.JqMA-btn-move)", function() {
if (Dscroll) {
dqSlt(".JqMA-btn-Ju").trigger("click");
pauseScroll = 1;
}
}).off("touchend.stopPause").on("touchend.stopPause", function() {
stopPause();
});
}
var scrollDiv = 0;
dqSlt("html").on('click', '.JqMA-btn-scrollDiv', function() {
scrollDiv += 1;
if (scrollDiv < 2) {
dqSlt(".JqMA-btn-scrollDiv").addClass("JqMA-css-colorG");
} else {
scrollDiv = 0;
dqSlt(".JqMA-btn-scrollDiv").removeClass("JqMA-css-colorG");
}
});
var timeout_3;
dqSlt("html").on('click', '.JqMA-btn-next', function() {
var pageDom = dqSlt(".pagetual_pageBar,.JqMA-mark-pageNext,.JqMA-inner-word");
var offsetDiffs = [];
pageDom.each(function(index, dom) {
var offsetD = -0.5 * (Drotate ? winWidth : winHeight);
if (Drotate) {
offsetD += $(this).offset().left - $(window).scrollLeft();
} else {
offsetD += $(this).offset().top - $(window).scrollTop();
}
if (offsetD > 1) {
offsetDiffs.push(offsetD);
}
});
if (offsetDiffs.length) {
offsetDiffs = offsetDiffs.sort(function(a, b) {
return a - b;
});
autoScrollBy(offsetDiffs[0]);
dqSlt(".JqMA-btn-next").html(pageDom.length - offsetDiffs.length);
}
}).on('touchmove', '.JqMA-btn-next', function() {
if (timeout_3) {
clearTimeout(timeout_3)
}
timeout_3 = setTimeout(function() {
var pageDom = dqSlt(".pagetual_pageBar,.JqMA-mark-pageNext,.JqMA-inner-word");
var offsetDiffs = [];
pageDom.each(function(ind, dom) {
var offsetD = -0.5 * (Drotate ? winWidth : winHeight);
if (Drotate) {
offsetD += $(this).offset().left - $(window).scrollLeft();
} else {
offsetD += $(this).offset().top - $(window).scrollTop();
}
if (offsetD < -1) {
offsetDiffs.push(offsetD)
}
});
if (offsetDiffs.length) {
offsetDiffs = offsetDiffs.sort(function(a, b) {
return b - a;
});
autoScrollBy(offsetDiffs[0]);
dqSlt(".JqMA-btn-next").html(offsetDiffs.length - 1);
}
}, 500);
});
var Dtransform = 0;
dqSlt("html").on('click', '.JqMA-btn-transform', function() {
Dtransform += 1;
if (Dtransform < 3) {
$(document.querySelector("body")).addClass("JqMA-css-transform");
addInner();
dqSlt(".JqMA-inner-html").addClass("JqMA-css-blank");
if (Dtransform == 1) {
dqSlt(":not(head *,.JqMA-btn-all,#pagetual-picker)").filter(function() {
return /sticky|fixed/.test($(this).css("position"));
}).addClass("JqMA-css-hide_fix JqMA-css-fixed");
autoScrollBy(1.5 * winHeight);
} else {
dqSlt(".JqMA-css-hide_fix").removeClass("JqMA-css-hide_fix");
}
dqSlt(".JqMA-btn-transform").addClass("JqMA-css-colorG").html("T" + Dtransform);
} else {
Dtransform = 0;
dqSlt(".JqMA-css-transform").removeClass("JqMA-css-transform");
dqSlt(".JqMA-css-fixed").removeClass("JqMA-css-fixed");
dqSlt(".JqMA-css-blank").removeClass("JqMA-css-blank");
autoScrollBy(-1.5 * winHeight);
dqSlt(".JqMA-btn-transform").removeClass("JqMA-css-colorG").html("T");
}
});
var timeout_9,
Drotate = 0;
dqSlt(".JqMA-btn-search").addClass("JqMA-css-colorG");
dqSlt("html").on('click', '.JqMA-btn-search', function() {
DSImg += 1;
if (DSImg == 2) {
DSImg = 0;
dqSlt(".JqMA-btn-search").removeClass("JqMA-css-colorG");
} else {
dqSlt(".JqMA-btn-search").addClass("JqMA-css-colorG");
}
if (picZ) {
picZ -= 1;
dqSlt(".JqMA-btn-pic").trigger("click");
}
}).on('touchmove', '.JqMA-btn-search', function() {
if (timeout_9) {
clearTimeout(timeout_9)
}
timeout_9 = setTimeout(function() {
var _scrollTop = getScrollTop(),
_scrollLeft = getScrollLeft();
autoScrollTo(0);
Drotate += 1;
if (Drotate < 2) {
dqSlt("html,body,div").filter(function() {
return $(this).css("overflow-y") != "hidden" &&
$(this).css("overflow-x") == "hidden" &&
$(this).height() > 0.5 * winHeight;
}).addClass("JqMA-css-xScroll");
setTimeout(function() {
$(document.querySelector('body')).addClass("JqMA-css-rotate");
autoScrollTo(_scrollTop * winProp);
dqSlt('.JqMA-btn-all').each(function() {
var _clone = $(this).clone().addClass("JqMA-btn-left")
.css('margin-left', (winHeight * winProp - winWidth * 0.8) + "px");
_clone.appendTo(document.querySelector("html"));
});
}, 100);
} else {
Drotate = 0;
setTimeout(function() {
dqSlt(".JqMA-css-rotate").removeClass("JqMA-css-rotate");
autoScrollTo(_scrollLeft / winProp);
dqSlt(".JqMA-btn-left").remove();
}, 100);
}
}, 500);
});
function getScrollLeft() {
return dqSlt("html").scrollLeft() + dqSlt("body").scrollLeft();
}
function getScrollTop() {
return dqSlt("html").scrollTop() + dqSlt("body").scrollTop();
}
var pauseScroll = 0,
Dpause;
dqSlt(".JqMA-btn-Ju,.JqMA-btn-down,.JqMA-btn-up").addClass("JqMA-btn-move");
dqSlt("html").on('click', "a,.JqMA-btn-down,.JqMA-btn-up", function() {
if (Dscroll) {
dqSlt(".JqMA-btn-Ju").trigger("click");
}
setTimeout(function() {
if (Dscroll) {
dqSlt(".JqMA-btn-Ju").trigger("click");
}
}, 210);
});
function stopPause() {
if (pauseScroll == 1) {
clearTimeout(Dpause);
Dpause = setTimeout(function() {
pauseScroll = 0;
if (!Dscroll) {
dqSlt(".JqMA-btn-Ju").trigger("click");
}
}, 200);
}
}
$(document).scroll(function() {
stopPause();
});
function visibleDiv() {
return dqSlt("div").filter(function() {
return $(this).css("overflow-y") != "hidden" &&
$(this).height() > 0.5 * winHeight;
});
}
function autoScrollBy(scrollBy_Ju, speed = 0) {
if (scrollDiv) {
visibleDiv().stop().animate({
scrollTop: "+=" + scrollBy_Ju + "px"
}, speed, "linear");
} else {
if (Drotate) {
dqSlt("html,body").stop().animate({
scrollLeft: "+=" + scrollBy_Ju + "px"
}, speed, "linear");
} else {
dqSlt("html,body").stop().animate({
scrollTop: "+=" + scrollBy_Ju + "px"
}, speed, "linear");
}
}
}
function autoScrollTo(scrollTo_Ju, speed = 0) {
if (scrollDiv) {
visibleDiv().stop().animate({
scrollTop: scrollTo_Ju
}, speed, "linear");
} else {
if (Drotate) {
dqSlt("html,body").stop().animate({
scrollLeft: scrollTo_Ju
}, speed, "linear");
} else {
dqSlt("html,body").stop().animate({
scrollTop: scrollTo_Ju
}, speed, "linear");
}
}
}
var timeout_4;
dqSlt("html").on('touchmove', '.JqMA-btn-width', function() {
if (timeout_4) {
clearTimeout(timeout_4)
}
timeout_4 = setTimeout(function() {
if (dqSlt(".JqMA-inner-word").length) {
dqSlt(".JqMA-inner-word").remove();
dqSlt('.JqMA-btn-width').removeClass("JqMA-css-colorG");
} else {
var allStr = "";
dqSlt(":not(head *,link,style,script,noscript)").each(function() {
var addStr = $(this).clone().children().remove().end().text().replace(/\s+/g, " ");
if (addStr.replace(/[^一-鿯0-9]/g, "").length > 6) {
allStr += "<br><br>";
}
allStr += addStr + " ";
});
addInner();
dqSlt(".JqMA-inner-html").prepend($("<div>").attr({
class: "JqMA-inner-word JqMA-inner-all"
}).html(allStr));
dqSlt('.JqMA-btn-width').addClass("JqMA-css-colorG");
}
}, 500);
});
var css_textImg,
css_textBig;
function fontInterFn() {
var fSize = widthN > 12 ? parseInt(winWidth / widthN) : 0;
dqSlt(":not(head *,link,style,script,noscript,.JqMA-css-textBig,.JqMA-inner-pic *,.JqMA-btn-all,#pagetual-picker *)").filter(function() {
var textLen = $(this).clone().children().remove().end().text()
.replace(/[0-9\s]+/g, "").length;
if (textLen > 0 && $(this).outerWidth() > 0.5 * winWidth) {
if (textLen > 50) {
oldFont = parseInt($(this).css("font-size").replace("px", ""));
}
return true;
}
return false;
}).addClass("JqMA-css-textBig");
var textBig = dqSlt(".JqMA-css-textBig");
removeCss(css_textBig);
css_textBig = addCss(".JqMA-css-textBig",
"font-size:" + fSize + "px !important;");
var _scale = fSize ? parseInt(fSize / oldFont * 100) / 100 : 1;
var DShadow = "grayscale(100%) contrast(200%) brightness(1000%)";
removeCss(css_textImg);
css_textImg = addCss(".JqMA-css-textImg",
`transform: scale(${_scale}) !important;
-webkit-transform: scale(${_scale}) !important;
-moz-transform: scale(${_scale}) !important;
margin: 0 ${_scale * 9 - 9}px !important;
filter: ${DShadow} !important;
-webkit-filter: ${DShadow} !important;
-moz-filter: ${DShadow} !important;`)
textBig.find("em:not(.JqMA-css-textBig),img").filter(function() {
return ($(this).is("img") || $(this).css("background-image").split(/[""'']/).length > 1) &&
$(this).outerWidth() < 0.1 * winWidth;
}).addClass("JqMA-css-textImg");
if (fSize) {
dqSlt(".JqMA-btn-width").html(21 - widthN);
} else {
textBig.removeClass("JqMA-css-textBig");
dqSlt(".JqMA-css-textImg").removeClass("JqMA-css-textImg");
dqSlt(".JqMA-btn-width").html("W");
}
}
function getTime() {
return Date.parse(new Date()) / 1000;
}
if (!GM_getValue("widthN") || getTime() - GM_getValue("widthN_time") > 600) {
GM_setValue("widthN", 10);
GM_setValue("widthN_time", getTime());
}
var widthN = GM_getValue("widthN"),
oldFont;
dqSlt("html").on('click', '.JqMA-btn-width', function() {
oldFont = 22;
widthN += 3;
if (widthN > 16) {
widthN -= 3 * 3;
}
fontInterFn();
GM_setValue("widthN", widthN)
GM_setValue("widthN_time", getTime());
});
function picSizeOut(_this, picwh_2 = null) {
var natureW = _this.naturalWidth;
var natureH = _this.naturalHeight;
if (!picwh_2) {
picwh_2 = picwh;
}
return natureW >= picwh_2 && natureH >= picwh_2 &&
natureW / natureH <= 6;
}
var timeout_10;
dqSlt("html").on('click', ".JqMA-btn-picwh", function() {
dqSlt(".JqMA-btn-all").addClass("JqMA-inner-hide_slt");
var _outStop = setTimeout(function() {
dqSlt("body").off("click.picwh");
dqSlt(".JqMA-btn-all").removeClass("JqMA-inner-hide_slt");
}, 3000);
setTimeout(function() {
dqSlt("body").on("click.picwh", function(event) {
var _target = $(event.target);
dqSlt("body").off("click.picwh");
dqSlt(".JqMA-btn-all").removeClass("JqMA-inner-hide_slt");
clearTimeout(_outStop);
if (_target.is(".JqMA-inner-pic .JqMA-mark-imgLoaded")) {
if (_target[0].naturalWidth < _target[0].naturalHeight) {
picwh = _target[0].naturalWidth + 1;
} else {
picwh = _target[0].naturalHeight + 1;
}
if (picwh < 50) {
picwh = 50;
}
} else {
picwh = 50;
}
picImgFilter();
dqSlt(".JqMA-btn-picwh").html(picwh);
});
}, 100);
}).on('touchmove', '.JqMA-btn-picwh', function() {
if (timeout_10) {
clearTimeout(timeout_10)
}
timeout_10 = setTimeout(function() {
picwh = 50;
picImgFilter();
dqSlt(".JqMA-btn-picwh").html(picwh);
}, 500);
});
function picImgFilter() {
if (picZ == 1) {
dqSlt(".JqMA-inner-pic br").addClass("JqMA-css-hide_br");
dqSlt(".JqMA-inner-pic xmp").css("css-text", "display: none !important;");
dqSlt(".JqMA-inner-pic .JqMA-mark-imgLoaded").filter(function() {
return picSizeOut(this);
}).each(function() {
$(this).closest(".JqMA-inner-pic > *")
.nextAll("br").slice(0, 9).removeClass("JqMA-css-hide_br");
$(this).closest(".JqMA-inner-pic > *")
.nextAll("xmp").slice(0, 9).css("css-text", "display: inline-block !important;");
}).removeClass("JqMA-css-smallPic").closest("picture").removeClass("JqMA-css-smallPic");
dqSlt(".JqMA-inner-pic .JqMA-mark-imgLoaded").filter(function() {
return !picSizeOut(this);
}).addClass("JqMA-css-smallPic").closest("picture").addClass("JqMA-css-smallPic");
} else {
dqSlt(".JqMA-inner-pic .JqMA-mark-imgLoaded").filter(function() {
return picSizeOut(this);
}).css("css-text", "display: inline-block !important;").closest("picture").css("css-text", "display: inline-block !important;");
dqSlt(".JqMA-inner-pic .JqMA-mark-imgLoaded").filter(function() {
return !picSizeOut(this);
}).css("css-text", "display: none !important;").closest("picture").css("css-text", "display: none !important;");
}
}
var timeout_1;
dqSlt("html").on('touchmove', '.JqMA-btn-pic', function() {
if (timeout_1) {
clearTimeout(timeout_1)
}
timeout_1 = setTimeout(function() {
if (picZ) {
picZ -= 1;
dqSlt(".JqMA-btn-pic").trigger("click");
}
}, 500);
});
var picZ = 0;
dqSlt("html").on('click', ".JqMA-btn-pic", function() {
getImgArr();
});
function getTrim(_str) {
try {
return _str.trim();
} catch (error) {
return null;
}
}
function getAttr(_this, _attr) {
return $(_this).attr(_attr) ? getTrim($(_this).attr(_attr)) : null;
}
function testHref(_href) {
return !/^javascript:|^#($|[A-Za-z_][A-Za-z0-9_]*$)/.test(_href);
}
function returnLength(lStr) {
var limitLen = 9;
if (picZ == 3) {
limitLen = 0;
}
return lStr.replace(/[0-9\s]+/g, "").replace(/[一-龟]/g, "aa").length > limitLen;
}
function imgInterFn() {
var newImgArr = [];
var _text = dqSlt("html").clone().find("head,link,style,script,noscript").remove().end().text()
.match(/http.*?[.](xbm|tif|pjp|svgz|jpg|jpeg|ico|tiff|gif|svg|jfif|webp|png|bmp|pjpeg|avif)/g);
if (picZ == 1 || picZ == 3) {
dqSlt("a").filter(function() {
return testHref(getAttr(this, "href")) && !/_blank/.test(getAttr(this, "target"));
}).attr({
target: "_blank",
rel: "noopener noreferrer"
}).addClass("JqMA-mark-aNewPage");
}
dqSlt(":not(html,.JqMA-mark-imgSelected,picture *,.JqMA-inner-pic *)").filter(function() {
var _img = $(this);
return _img.has("img").length || _img.is("a,img,.pagetual_pageBar") || _img.css("background-image").split(/[""'']/).length > 1;
}).each(function(inum, dom) {
var dataObj = [],
_img = $(this),
_picStr = null,
_imgStr = null;
_img.addClass("JqMA-mark-imgSelected");
if (inum == 0 || (_img.is(".pagetual_pageBar") && inum > 9)) {
newImgArr.push($("<div>").attr({
class: "JqMA-mark-pageNext"
}));
}
if (picZ != 3) {
if (inum == 0 && _text) {
dataObj = dataObj.concat(_text);
}
if (_img.is("picture")) {
_picStr = $("<picture>");
var _picChild;
_img.children().each(function() {
if ($(this).is("img")) {
_picChild = $("<img>").attr({
width: "300",
height: "100",
alt: "JU-IMG",
src: getAttr(this, "src"),
});
} else {
_picChild = $("<source>");
}
_picStr.append(_picChild.attr({
srcset: getAttr(this, "srcset"),
media: getAttr(this, "media"),
type: getAttr(this, "type"),
}));
preImgArr.push(getAttr(this, "srcset"));
preImgArr.push(getAttr(this, "src"));
});
_picStr = _picStr.prop("outerHTML");
if (preImgArr.indexOf(_picStr) == -1) {
preImgArr.push(_picStr);
newImgArr.push(_picStr);
} else {
_picStr = null;
}
}
var _backImg = _img.css("background-image").split(/[""'']/);
dataObj.push(getAttr(_img, "src"));
dataObj.push(_backImg.length > 1 ? _backImg[1] : null);
if (DSImg != 0) {
var _attributes = [],
_data = Object.values(_img.data());
_attributes.push(_img[0].attributes);
if (_img.is("picture")) {
_img.children().each(function() {
_attributes.push(this.attributes);
_data = _data.concat(Object.values($(this).data()));
});
}
_attributes.forEach(function(attrs) {
$.each(attrs, function(index, item) {
if (!/^(src|style|srcset|class|id|type|href|onclick)$|^data-|^:/.test(item.name)) {
_data.push(item.value);
}
});
});
_data.forEach(function(i) {
if (typeof i == "object") {
try {
i = JSON.stringify(i);
} catch (error) {
return;
}
} else if (typeof i != "string") {
return;
}
if (/[""'']|%22%2C/.test(i)) {
var _isp = i.split(/[""'']|%22/).filter(function(j) {
return j.length > 9 && /^http/.test(getTrim(j));
});
dataObj = dataObj.concat(_isp);
} else {
dataObj.push(i);
}
});
}
dataObj = Array.from(new Set(dataObj));
dataObj.forEach(function(i) {
if (typeof i != "string") {
return
}
i = getTrim(i);
try {
i = decodeURIComponent(i);
i = decodeURI(i);
i = unescape(i);
} catch (error) {
console.log(error);
}
if (/^data:image/.test(i)) {
i = i.replace(/[^A-Za-z0-9+/=>;]{0,9}$/, "");
}
if (/^[a-z/]/.test(i) && /[?/]/.test(i) &&
!/[.](txt|shtml|html|htm)$/.test(i) &&
preImgArr.indexOf(i) == -1) {
preImgArr.push(i);
_imgStr = $("<img>").attr({
src: i,
loading: "lazy",
alt: "JU-IMG",
width: "300",
height: "100",
srcset: getAttr(_img, "srcset")
}).prop("outerHTML");
newImgArr.push(_imgStr);
}
});
}
if (_imgStr || _picStr || (picZ == 3 && _img.is("a"))) {
var _a = _img.find("a").first();
if (!_a.length) {
_a = _img.closest("a");
}
var _img_2 = _img;
for (var i = 0; i < 9; i++) {
if (_a.length || _img_2.is("body")) {
break;
} else {
_a = _img_2.siblings("a").first();
if (!_a.length) {
_a = _img_2.siblings().find("a").first();
}
_img_2 = _img_2.parent();
}
}
var _newA = $("<a>").html("IMG");
var _imgText = _img.clone().find("head,link,style,script,noscript").remove().end().text();
var _pStr = (_img.attr("alt") && returnLength(_img.attr("alt")) ? _img.attr("alt") :
_img.attr("title") ? _img.attr("title") :
returnLength(_imgText) ? _imgText :
"");
var _aHref = null;
if (_a.length) {
_aHref = getAttr(_a, "href");
if (picZ != 3) {
var _a_2 = _a;
for (var i = 0; i < 9; i++) {
if (_pStr != "" || _a_2.is("body")) {
break
} else {
_imgText = _a_2.clone().find("head,link,style,script,noscript").remove().end().text();
_pStr = (_a_2.attr("title") ? _a_2.attr("title") :
returnLength(_imgText) ? _imgText :
"");
_a_2 = _a_2.parent();
}
}
}
_newA.on("click", function() {
_a.trigger("click");
});
if (_aHref) {
_newA.attr({
href: _aHref
});
if (testHref(_aHref)) {
_newA.attr({
target: "_blank",
rel: "noopener noreferrer"
});
}
var hrefImg = _aHref.match(/http.*?[.](xbm|tif|pjp|svgz|jpg|jpeg|ico|tiff|gif|svg|jfif|webp|png|bmp|pjpeg|avif)/g);
if (DSImg != 0 && hrefImg) {
hrefImg = hrefImg[0];
try {
hrefImg = decodeURIComponent(hrefImg);
hrefImg = decodeURI(hrefImg);
hrefImg = unescape(hrefImg);
} catch (error) {
console.log(error);
}
if (preImgArr.indexOf(hrefImg) == -1) {
preImgArr.push(hrefImg);
_imgStr = $("<img>").attr({
src: hrefImg,
loading: "lazy",
alt: "JU-IMG",
width: "300",
height: "100",
srcset: getAttr(_img, "srcset")
}).prop("outerHTML");
newImgArr.push(_imgStr);
}
}
}
}
if (!(_a.length && _aHref && testHref(_aHref))) {
_newA.on("click", function() {
_img.trigger("click");
});
}
_pStr = getTrim(_pStr).replace(/\s+/g, " ").substring(0, 99);
if (picZ == 1 || (picZ == 3 && preImgArr.indexOf(_pStr) == -1)) {
preImgArr.push(_pStr);
if (picZ == 3) {
newImgArr.push($("<xmp>"));
}
newImgArr.push($("<br>").addClass("JqMA-css-hide_br"));
newImgArr.push(_newA);
newImgArr.push($("<xmp>").html(_pStr));
newImgArr.push(_newA.clone(true).attr("class", "JqMA-clone-a"));
}
}
});
newImgArr = Array.from(new Set(newImgArr));
if (newImgArr.toString() != imgArr.toString() && newImgArr.length > 1) {
var newArrEx = newImgArr.filter(function(n) {
return imgArr.indexOf(n) == -1;
});
imgArr = imgArr.concat(newArrEx);
dqSlt(".JqMA-inner-pic").append(newArrEx);
dqSlt(".JqMA-inner-pic img").off("error.imgError").on("error.imgError", function() {
if (getAttr(this, "src").indexOf("=http") > -1) {
$(this).attr("src", getAttr(this, "src").replace(/(?<==http.*?)&.*$/, "").replace(/^.*=(?=http)/, ""));
}
if (picZ == 1 && !/^data:image/.test(getAttr(this, "src"))) {
$(this).addClass("JqMA-css-smallPic").closest("picture").addClass("JqMA-css-smallPic");
} else {
$(this).css("css-text", "display: none !important;").closest("picture").css("css-text", "display: none !important;");
}
});
dqSlt(".JqMA-inner-pic img:not(.JqMA-mark-imgLoaded)").on("load", function() {
$(this).addClass("JqMA-mark-imgLoaded");
if (picSizeOut(this)) {
if (picZ == 1) {
$(this).removeClass("JqMA-css-smallPic").closest("picture").removeClass("JqMA-css-smallPic");
$(this).closest(".JqMA-inner-pic > *")
.nextAll("br").slice(0, 9).removeClass("JqMA-css-hide_br");
$(this).closest(".JqMA-inner-pic > *")
.nextAll("xmp").slice(0, 9).css("css-text", "display: inline-block !important;");
} else {
$(this).css("css-text", "display: inline-block !important;").closest("picture").css("css-text", "display: inline-block !important;");
}
} else {
if (picZ == 1) {
$(this).addClass("JqMA-css-smallPic").closest("picture").addClass("JqMA-css-smallPic");
} else {
$(this).css("css-text", "display: none !important;").closest("picture").css("css-text", "display: none !important;");
}
}
});
}
if (picZ == 3) {
dqSlt(".JqMA-inner-pic > xmp,.JqMA-inner-pic br").css("css-text", "display: inline-block !important;");
}
}
var imgArr,
preImgArr;
function getImgArr() {
dqSlt(".JqMA-inner-pic").remove();
dqSlt(".JqMA-mark-imgSelected").removeClass("JqMA-mark-imgSelected");
dqSlt(".JqMA-mark-aNewPage").removeClass("JqMA-mark-aNewPage").removeAttr("target rel");
picZ += 1;
if (picZ < 4) {
addInner();
dqSlt(".JqMA-inner-html").prepend($("<div>").attr({
class: "JqMA-inner-pic JqMA-inner-all"
}));
picwh = 50;
imgArr = [];
preImgArr = [];
dqSlt(".JqMA-btn-picwh").html(picwh);
dqSlt(".JqMA-btn-pic").addClass("JqMA-css-colorG").html("P" + picZ);
imgInterFn();
} else {
dqSlt(".JqMA-btn-pic").removeClass("JqMA-css-colorG").html("P");
picZ = 0;
}
}
var pageX = [],
timeout_6;
dqSlt("html").on('click', '.JqMA-btn-down', function() {
pageX.unshift([getScrollLeft(), getScrollTop()]);
var toHs = [];
$(document.querySelectorAll("body > *:not(link,style,script,noscript)")).each(function() {
var toH = -0.5 * (Drotate ? winWidth : winHeight);
if (Drotate) {
toH += $(this).offset().left - $(window).scrollLeft();
} else {
toH += $(this).offset().top - $(window).scrollTop();
}
toH += $(this).outerHeight();
toHs.push(toH);
});
if (!scrollDiv && toHs.length) {
toHs.sort(function(a, b) {
return b - a;
});
autoScrollBy(toHs[0]);
} else {
autoScrollBy(1000 * winHeight);
}
}).on('touchmove', '.JqMA-btn-down,.JqMA-btn-up', function() {
if (timeout_6) {
clearTimeout(timeout_6)
}
timeout_6 = setTimeout(function() {
if (pageX.length) {
pageX = uniqueArr(pageX);
autoScrollTo(Drotate ? pageX[0][0] : pageX[0][1]);
pageX.splice(0, 1);
}
}, 510);
});
dqSlt("html").on('click', '.JqMA-btn-up', function() {
pageX.unshift([getScrollLeft(), getScrollTop()]);
if (scrollDiv) {
autoScrollBy(-1000 * winHeight);
return;
}
if (Dtransform) {
autoScrollTo(1.5 * winHeight);
} else {
autoScrollTo(0);
}
});
function delHide() {
dqSlt(".JqMA-btn-all").addClass("JqMA-css-hide_btn");
dqSlt(".JqMA-btn-del").each(function() {
this.style.setProperty("opacity", "0.3", 'important');
}).removeClass("JqMA-css-hide_btn");
Dhide = 1;
}
var Dhide = 0,
timeout_2;
dqSlt("html").on('click', '.JqMA-btn-del', function() {
if (!Dhide) {
delHide();
} else {
Dhide = 0;
dqSlt(".JqMA-btn-all").each(function() {
this.style.setProperty("opacity", "0.6", 'important');
}).removeClass("JqMA-css-hide_btn");
}
}).on('touchmove', '.JqMA-btn-del', function() {
if (timeout_2) {
clearTimeout(timeout_2);
}
timeout_2 = setTimeout(function() {
dqSlt(".JqMA-btn-all").each(function() {
this.style.setProperty("opacity", "0.1", 'important');
});
Dhide = 1;
}, 500);
});
var timeout_7;
dqSlt("html").on('click', '.JqMA-btn-jia', function() {
scrollJu += 1;
if (scrollJu * scrollNum > winHeight - 50) {
scrollJu = 0;
}
dqSlt(".JqMA-btn-Ju").html(scrollJu);
}).on('touchmove', '.JqMA-btn-jia', function() {
if (timeout_7) {
clearTimeout(timeout_7)
}
timeout_7 = setTimeout(function() {
scrollJu += 6;
if (scrollJu * scrollNum > winHeight - 50) {
scrollJu = 0;
}
dqSlt(".JqMA-btn-Ju").html(scrollJu);
}, 500);
});
var timeout_8;
dqSlt("html").on('click', '.JqMA-btn-jian', function() {
scrollJu -= 1;
if (-scrollJu * scrollNum > winHeight - 50) {
scrollJu = 0;
}
dqSlt(".JqMA-btn-Ju").html(scrollJu);
}).on('touchmove', '.JqMA-btn-jian', function() {
if (timeout_8) {
clearTimeout(timeout_8)
}
timeout_8 = setTimeout(function() {
scrollJu -= 6;
if (-scrollJu * scrollNum > winHeight - 50) {
scrollJu = 0;
}
dqSlt(".JqMA-btn-Ju").html(scrollJu);
}, 500);
});
var timeout_5;
dqSlt("html").on('touchmove', '.JqMA-btn-Ju', function() {
if (timeout_5) {
clearTimeout(timeout_5)
}
timeout_5 = setTimeout(function() {
scrollJu = 0;
dqSlt(".JqMA-btn-Ju").html(scrollJu);
}, 500);
});
var Dscroll = 0;
var timeDown;
dqSlt("html").on('click', '.JqMA-btn-Ju', function() {
Dscroll += 1;
clearInterval(timeDown);
if (Dscroll < 2) {
dqSlt(".JqMA-btn-Ju").addClass("JqMA-css-colorG");
autoScrollBy(scrollJu * scrollNum, scrollJu > 9 || scrollJu < -9 ? 0 : animateTime);
timeDown = setInterval(function() {
autoScrollBy(scrollJu * scrollNum, scrollJu > 9 || scrollJu < -9 ? 0 : animateTime);
}, animateTime + 10);
} else {
Dscroll = 0;
dqSlt("html,body").stop();
visibleDiv().stop();
dqSlt(".JqMA-btn-Ju").removeClass("JqMA-css-colorG");
}
});
// Your code here...
})(this.jQuery);