// ==UserScript==
// @name 手机助手
// @namespace http://tampermonkey.net/
// @version 9.500.16.31
// @description 自动滚动,嗅探图片、视频,字体放大,去除广告浮动
// @author You
// @match *://*/*
// @run-at document-start
// @require https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js
// @grant GM_registerMenuCommand
// @grant GM_setValue
// @grant GM_getValue
// @license MIT
// ==/UserScript==
{
let hengPin = screen.orientation.lock;
let runFunc = setInterval(function() {
if (!jQuery) return;
let dom = {};
dom.jQuery = jQuery.noConflict(true);
clearInterval(runFunc);
(function($) {
'use strict';
if (document.querySelector('.JqMA-btn-all') || window.frames.length != parent.frames.length) {
return;
}
function dqSlt(selectPath) {
try {
return $(document.querySelectorAll('iframe')).contents().find(selectPath).add(selectPath);
} catch (error) {
return $(document.querySelectorAll('iframe')).contents().find(selectPath).add(document.querySelectorAll(selectPath));
}
}
function removeShadowRoot() {
var hasShadowRoot;
$(document.querySelectorAll("div")).each(function() {
if (this.shadowRoot) {
this.replaceWith(...this.shadowRoot.childNodes);
hasShadowRoot = true;
}
});
alert(hasShadowRoot ? "#shadow-root 已移除" : "#shadow-root 不存在");
}
function checkImgExists(imgurl) {
return new Promise(function(resolve, reject) {
var ImgObj = new Image();
ImgObj.src = imgurl;
ImgObj.onload = function(res) {
resolve(this);
}
ImgObj.onerror = function(err) {
reject(err)
}
});
}
function getTouchSite(_element, event) {
var rect = _element.getBoundingClientRect();
var offsetY = event.touches[0].clientY - rect.top - $(_element).height() / 2;
var offsetX = event.touches[0].clientX - rect.left - $(_element).height() / 2;
return [offsetX, offsetY];
}
function getElementSelector(element) {
var path = "";
while (element && element.nodeType == Node.ELEMENT_NODE) {
var selector = element.nodeName.toLowerCase();
if (selector == "body") {
break;
}
if (element.id) {
selector += "#" + element.id;
} else {
if (element.classList.length > 0) {
selector += "." + Array.from(element.classList)[element.classList.length - 1];
}
if (element.parentNode.querySelectorAll(selector).length > 1) {
var index = Array.from(element.parentNode.children).indexOf(element) + 1;
selector += ":nth-child(" + index + ")";
}
}
path = selector + " > " + path;
element = element.parentNode;
}
return "body > " + path.replace(/[> ]+$/, "");
}
function documentCopy(copyText) {
var _input = $("<input style='position:fixed!important;clip:rect(0 0 0 0)!important;top: 10px!important;'>").val(copyText).appendTo(document.body);
_input[0].select();
document.execCommand('copy');
_input.remove();
}
function copyToClipboard(copyText) {
try {
navigator.clipboard.writeText(copyText).catch(() => {
documentCopy(copyText);
});
} catch (error) {
documentCopy(copyText);
}
}
function getDataValue(gmValName, _default) {
if (typeof GM_getValue(gmValName) != "object") {
GM_setValue(gmValName, {});
}
var _data = GM_getValue(gmValName),
keys = Object.keys(_data);
if (gmValName != "picRepData" && keys.length > 100) {
delete _data[keys[0]];
}
return [_data, _data.hasOwnProperty(locHost()) ? _data[locHost()] : _default];
}
if (GM_getValue("hidePagetual") === null) GM_setValue("hidePagetual", 0);
var hidePagetual = GM_getValue("hidePagetual");
GM_registerMenuCommand("1:隐藏按钮 2:隐藏东方", function() {
var isHide = $(document.querySelector(".JqMA-btn-del")).css("display") == "none";
var inputNum = window.prompt("1:" + (isHide ? "显示" : "隐藏") + "按钮 2:" + (hidePagetual ? "显示" : "隐藏") + "东方永页机按钮", 1);
if (inputNum === "1") {
if (isHide) {
dqSlt(Dhide ? ".JqMA-btn-del" : ".JqMA-btn-all").each(function() {
this.style.cssText += "display:block!important;" +
(Dhide ? "opacity:0.5!important;" : "");
});
} else {
dqSlt(".JqMA-btn-all").each(function() {
this.style.cssText += "display:none!important;";
});
}
} else if (inputNum === "2") {
hidePagetual = hidePagetual ? 0 : 1;
GM_setValue("hidePagetual", hidePagetual);
location.reload(false);
}
});
function changeDataFunc(_data, _default) {
var changeData = window.prompt("请修改:", JSON.stringify(_data));
if (typeof JSON.parse(changeData) == "object") {
changeData && alert(changeData);
changeData = JSON.parse(changeData)
return [changeData, changeData.hasOwnProperty(locHost()) ? changeData[locHost()] : _default]
} else {
return false;
}
}
var html_style =
`html,body {
overflow-wrap: break-word!important;
scroll-behavior: auto!important;
min-height: 100vh!important;
}`;
var inner_style =
`.JqMA-inner-all{
position: relative !important;
z-index: 2147483646 !important;
margin:20vh 0 5vh 0!important;
border: 0 !important;
padding: 0 !important;
width: 100% !important;
height: auto !important;
background: black !important;
display: block !important;
}
.JqMA-inner-all,
.JqMA-inner-pic * {
box-sizing: border-box !important;
border-radius: 0 !important;
float: none !important;
opacity: 1 !important;
visibility: visible !important;
overflow-wrap: break-word !important;
}
html body .JqMA-inner-word {
color: #FEFEFE!important;
text-align: left!important;
font-size: 3vh!important;
text-indent: 2em!important;
}
.JqMA-inner-pic {
text-align: center !important;
font: 0 "Fira Sans", sans-serif !important;
}
.JqMA-inner-pic *{
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 img {
display: inline-block !important;
width: 100% !important;
height: auto !important;
object-fit: contain !important;
background: gray !important;
}
html .JqMA-inner-pic > *{
vertical-align: top !important;
overflow: hidden !important;
}
.JqMA-inner-pic a ,
.JqMA-mark-pageNum {
background: none!important;
color: #FEFEFE!important;
height: 8vw!important;
font-size: 2.5vh!important;
line-height: 1.36!important;
text-align: center!important;
}
.JqMA-mark-pageNum {
width: 100%!important;
}
html .JqMA-inner-pic > img + a {
margin-top:-16vw!important;
}
html .JqMA-inner-pic > img + a + a{
margin-top:-8vw!important;
}
.JqMA-inner-pic img.JqMA-css-smallPic {
width: 12.5%!important;
height: 8vw!important;
}
.JqMA-inner-pic p > a{
display: inline!important;
}
.JqMA-inner-pic > a {
display: inline-block!important;
width: 12.5%!important;
border: 2px solid red!important;
margin-right: 43.75%!important;
margin-left: 43.75%!important;
background: rgba(0,0,0,0.2)!important;
}
.JqMA-inner-pic > a.JqMA-css-smallPic {
display: none!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 {
overflow: hidden!important;
opacity: 1!important;
background: rgba(0,0,0,0.4)!important;
color: #FEFEFE!important;
display: block!important;
text-align: center!important;
line-height: 2.8!important;
border-radius: 0!important;
user-select: none!important;
z-index: 999999999999!important;
margin: 0!important;
padding: 0!important;
border: 0!important;
font-weight: bold!important;
position: fixed!important;
font-size: calc(1.5vh + 0.6vw)!important;
height: calc(4.2vh + 1.6vw)!important;
width: calc(4.2vh + 1.6vw)!important;
}
`;
var css_style =
`.JqMA-mark-pageNext:not(.JqMA-mark-pageNum) {
display: inline-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 {
letter-spacing: normal !important;
line-height: normal !important;
overflow-wrap: break-word !important;
}
.JqMA-css-fixed_hide {
display: none !important;
}
.JqMA-css-overY_auto{
overflow-y: auto!important;
}
.JqMA-css-transform {
transform: translate(0%, 0%) !important;
padding: 50vh 0!important;
height: auto !important;
max-height: none !important;
}`;
if (hidePagetual) {
css_style += `.pagetual_pageBar,#pagetual-sideController {
display: inline-block !important;
height: 0 !important;
min-height: none !important;
margin: 0 !important;
border: 0 !important;
padding: 0 !important;
overflow: hidden !important;}`;
}
function locHost() {
return window.location.hostname;
}
function getValLoc(gmValName, _default) {
if (GM_getValue(gmValName) === null) {
GM_setValue(gmValName, _default);
}
if (locHost() == GM_getValue(gmValName + "_locH")) {
return GM_getValue(gmValName)
} else {
return _default;
}
}
function setValLoc(gmValName, value) {
GM_setValue(gmValName, value);
GM_setValue(gmValName + "_locH", locHost());
}
if (GM_getValue("scrollJu") === null) GM_setValue("scrollJu", 5);
var scrollJu = Math.abs(GM_getValue("scrollJu"));
var [DSImgData, DSImg] = getDataValue("DSImgData", 0);
var picwh = getValLoc("picwh", 50);
var outerSz = getValLoc("outerSz", 40);
if (GM_getValue("smoothScroll") === null) GM_setValue("smoothScroll", 0);
var smoothScroll = GM_getValue("smoothScroll");
var direction = 1;
function addInput(class1, value1, style1) {
$(document.querySelector("html")).append($('<p>').attr({
class: "JqMA-btn-all " + class1,
style: style1 + "!important;left: 0!important;"
}).text(value1));
}
addInput('JqMA-btn-del', 'X', "top:calc(47.9vh - 0.8vw)");
addInput('JqMA-btn-width', 'W', "top:calc(43.7vh - 2.4vw)");
addInput('JqMA-btn-Ju', (smoothScroll ? "`" : "") + scrollJu, "top:calc(39.5vh - 4vw)");
addInput('JqMA-btn-down', '▽', "top:calc(35.3vh - 5.6vw)");
addInput('JqMA-btn-next', 'N', "top:calc(31.1vh - 7.2vw)");
addInput('JqMA-btn-scrollDiv', "O", "top:calc(26.9vh - 8.8vw)");
// addInput('JqMA-btn-', "", "top:calc(22.7vh - 10.4vw)");
addInput('JqMA-btn-transform', "T", "top:calc(52.1vh + 0.8vw)");
addInput('JqMA-btn-blank ', 'B', "top:calc(56.3vh + 2.4vw)");
addInput('JqMA-btn-pic', 'P', "top:calc(60.5vh + 4vw)");
addInput('JqMA-btn-picwh', picwh, "top:calc(64.7vh + 5.6vw)");
addInput('JqMA-btn-outerSz', outerSz, "top:calc(68.9vh + 7.2vw)");
// addInput('JqMA-btn-', , "top:calc(73.1vh + 8.8vw)");
var Dhide = getValLoc("Dhide", 1);
Dhide && delHide();
setTimeout(function() {
if (Dtransform) {
Dtransform = 0;
$(document.querySelector(".JqMA-btn-transform")).trigger("click");
}
widthN && dqSlt(".JqMA-btn-width").text(widthN);
picZ && dqSlt(".JqMA-btn-pic").each(function() {
this.style.setProperty("color", "green", "important");
});
openBlank && dqSlt(".JqMA-btn-blank").each(function() {
this.style.setProperty("color", "green", "important");
});
scrollDiv && dqSlt(".JqMA-btn-scrollDiv").each(function() {
this.style.setProperty("color", "green", "important");
});
DSImg && dqSlt(".JqMA-btn-picwh").each(function() {
this.style.setProperty("color", "green", "important");
});
firstRun();
}, 200);
$(document.querySelector("head:not([JqMA-mark-addStyle])")).append(
$("<style>").html(html_style + inner_style + css_style)
).attr("JqMA-mark-addStyle", 1);
var _timeTouch;
function touchRun() {
clearTimeout(_timeTouch);
_timeTouch = setTimeout(function() {
firstRun();
for (let i = 0; i < 20; i++) {
setTimeout(function() {
clearTimeout(_timeTouch);
}, i * 100);
}
}, 300);
}
function firstRun() {
if (nextScrollTop && $(document.querySelector("body")).height() > nextScrollTop + window.innerHeight) {
autoScrollTo(nextScrollTop);
nextScrollTop = 0;
}
dqSlt(":not([JqMA-mark-backImg])").filter(function() {
return $(this).css("background-image").split(/[""]/).length > 1;
}).attr("JqMA-mark-backImg", 1);
dqSlt("head:not([JqMA-mark-addStyle])").append(
$("<style>").html(css_style)
).attr("JqMA-mark-addStyle", 1);
Dtransform && transformFunc();
widthN && fontInterFn();
picZ && imgInterFn();
openBlank && aOpenBlank();
!Dhide && xiuTan();
dqSlt("body:not(body *,[JqMA-mark-bodyFunc])").on('click', function(event) {
let _target = $(event.target);
if (_target.is("a")) {
setTimeout(function() {
Dscroll && $(document.querySelector(".JqMA-btn-Ju")).trigger("click");
}, 210);
}
if (_target.is("#JqMA-mark-pageNext_1,#JqMA-mark-pageNext_2")) {
pageX.unshift(getScrollTop());
document.querySelector("." + _target.attr("id")).scrollIntoView();
} else if (!_target.is("a,a *")) {
direction = event.clientY < window.innerHeight / 9 ? -1 : 1;
if (widthN) {
autoScrollBy(direction * 0.93 * window.innerHeight);
} else if (picZ || Dtransform || (_target.is("img,[JqMA-mark-backImg],:has(img,[JqMA-mark-backImg])") &&
getMinOuter(_target[0]) > 0.2 * window.innerWidth)) {
autoScrollBy(direction * 0.45 * window.innerHeight);
}
}
}).attr("JqMA-mark-bodyFunc", 1);
dqSlt("html:not(html *,[JqMA-mark-htmlFunc])").on("touchstart touchend", function(event) {
if (Dscroll) {
let _target = $(event.target);
if (!_target.is(".JqMA-btn-Ju")) {
$(document.querySelector(".JqMA-btn-Ju")).trigger("click");
if (!_target.is(".JqMA-btn-down")) {
pauseScroll = 1;
stopPause();
}
}
}
}).on("touchend", function() {
touchRun();
}).attr("JqMA-mark-htmlFunc", 1);
}
var pauseScroll,
pauseScTime;
function stopPause() {
if (pauseScroll) {
clearTimeout(pauseScTime);
pauseScTime = setTimeout(function() {
pauseScroll = 0;
Dscroll || $(document.querySelector(".JqMA-btn-Ju")).trigger("click");
}, 200);
}
}
$(document).scroll(function() {
stopPause();
});
$.fn.slideScreen = function(_target, fn, trsTime) {
var timeout_1;
$(this).on('touchmove', _target, function(event) {
clearTimeout(timeout_1)
timeout_1 = setTimeout(function() {
fn(event);
}, trsTime || 500);
});
}
$.fn.longPress = function(_target, fn, trsTime) {
var timeout_2;
$(this).on('touchstart', _target, function(event) {
timeout_2 = setTimeout(function() {
fn(event);
document.getSelection().removeAllRanges();
}, trsTime || 500);
}).on('touchend touchmove', _target, function(event) {
clearTimeout(timeout_2)
});
}
var scrollDiv = getValLoc("scrollDiv", 0);
dqSlt("html").on('click', '.JqMA-btn-scrollDiv', function() {
scrollDiv = scrollDiv ? 0 : 1;
dqSlt(".JqMA-btn-scrollDiv").each(function() {
this.style.setProperty("color", scrollDiv ? "green" : null, "important");
});
setValLoc("scrollDiv", scrollDiv)
}).slideScreen('.JqMA-btn-scrollDiv', function() {
removeShadowRoot();
});
dqSlt("html").longPress('.JqMA-btn-scrollDiv', function() {
location.reload()
});
dqSlt("html").on('click', '.JqMA-btn-next', function() {
var inputNum = window.prompt("跳转第几个节点:", $(document.querySelector(".JqMA-btn-next")).text());
if (Number(inputNum) || inputNum === "0") {
var nextNum = Number(inputNum);
pageNextFunc(nextNum);
}
}).slideScreen('.JqMA-btn-next', function(event) {
var [offsetX, offsetY] = getTouchSite(event.target, event);
if (offsetY > 30) {
pageNextFunc("up");
} else if (offsetY < -30 || offsetX > 40) {
pageNextFunc("down");
}
});
function pageNextFunc(nextNum) {
pageX.unshift(getScrollTop());
var pageDom = dqSlt(".pagetual_pageBar,.JqMA-mark-pageNext,.JqMA-inner-all,.JqMA-inner-all > :visible:last"),
offsetDiffs = [];
if (nextNum >= pageDom.length) {
pageDom.last()[0].scrollIntoView();
dqSlt(".JqMA-btn-next").text(pageDom.length - 1);
}
$(nextNum == "up" ? pageDom.get().reverse() : pageDom).each(function(index, dom) {
let offsetD = this.getBoundingClientRect().top;
if (nextNum == index || (nextNum == "up" && offsetD < -0.25 * window.innerHeight) ||
(nextNum == "down" && offsetD > 0.25 * window.innerHeight)) {
this.scrollIntoView();
dqSlt(".JqMA-btn-next").text(nextNum == "up" ? pageDom.length - index - 1 : index);
return false;
}
});
}
function transformFunc() {
dqSlt(":visible:not(.JqMA-css-fixed_hide,.JqMA-btn-all,#pagetual-picker)").filter(function() {
return /sticky|fixed/.test($(this).css("position")) && this.clientHeight < 0.5 * window.innerHeight;
}).addClass("JqMA-css-fixed_hide");
}
var Dtransform = getValLoc("Dtransform", 0);
dqSlt("html").on('click', '.JqMA-btn-transform', function() {
Dtransform = Dtransform ? 0 : 1;
dqSlt(".JqMA-btn-transform").each(function() {
this.style.setProperty("color", Dtransform ? "green" : null, "important");
});
if (Dtransform) {
$(document.querySelector("html")).filter(function() {
return $(this).css("overflow-y") == "hidden";
}).addClass("JqMA-css-overY_auto");
$(document.querySelector("body")).addClass("JqMA-css-transform");
transformFunc();
} else {
dqSlt(".JqMA-css-transform,.JqMA-css-overY_auto").removeClass("JqMA-css-transform JqMA-css-overY_auto");
dqSlt(".JqMA-css-fixed_hide").removeClass("JqMA-css-fixed_hide");
}
autoScrollBy((Dtransform ? 0.5 : -0.5) * window.innerHeight, 0, 0);
setValLoc("Dtransform", Dtransform);
}).slideScreen('.JqMA-btn-transform', function() {
dqSlt(".JqMA-btn-all").each(function() {
this.style.setProperty("display", "none", "important");
});
setTimeout(function() {
dqSlt("body").on("click.tempClickFunc", function(event) {
event.preventDefault();
dqSlt("body").off("click.tempClickFunc");
dqSlt(".JqMA-btn-all").each(function() {
this.style.setProperty("display", "block", "important");
});
if (window.confirm("是否复制图片链接?")) copyToClipboard(event.target.currentSrc);
setTimeout(function() {
var inputNum = window.prompt("请输入图片链接替换(`分隔,@开头:正则且数字->[0-9]):", picReplace);
if (inputNum == "所有域名") {
var resultData = changeDataFunc(picRepData, "");
if (resultData)[picRepData, picReplace] = resultData;
} else if (typeof inputNum === "string") {
picReplace = inputNum;
if (picReplace === "") {
delete picRepData[locHost()];
} else {
picRepData[locHost()] = picReplace;
if (picZ) {
var _scrollTop = getScrollTop();
removePicClass();
imgInterFn();
setTimeout(function() {
autoScrollTo(_scrollTop);
}, 400);
}
}
}
GM_setValue("picRepData", picRepData);
}, 200);
});
}, 100);
});
dqSlt("html").longPress('.JqMA-btn-transform', function() {
alert(`O:
==点击:切换滚动对象
==滑动:移除#shadow-root
==长按:刷新页面
N:
==点击:输入跳转节点
==滑动:上/下:下/上一节点
▽:
==点击:回上一位置
==滑动:上/下:到底/顶部
==长按:记录本域名滚动位置
5:
==点击:启动/停止滚动
==滑动:上加下减
==长按:输入滚动速度
W:
==点击:输入字体大小
==滑动:上加下减
==长按:朗读或下载文字
X:
==点击:隐藏/显示其他按钮
==滑动:触发 立即翻页 按钮
==长按:自动点击下一页
T:
==点击:元素取消浮动
==滑动:点击图片,输入替换规则
==长按:显示操作清单
B:
==点击:切换a链接打开方式
==滑动:点击2个a链接,加载页面
==长按:横屏全屏,返回键退出
P:
==点击:页首添加图片集
==滑动:滚动加载图片集
50:
==点击:点击图片,修改过滤尺寸
==滑动:上加下减
==长按:开关深度搜索
40:
==点击:点击元素,修改过滤尺寸
==滑动:上加下减,右加`);
});
var [picRepData, picReplace] = getDataValue("picRepData", "");
function getScrollTop() {
if (scrollDiv) {
return visibleDiv().scrollTop();
} else {
return document.querySelector("html").scrollTop +
document.querySelector("body").scrollTop;
}
}
function visibleDiv(scDiv = null) {
scDiv = scDiv === null ? scrollDiv : scDiv;
let visDiv = $(document.querySelectorAll("html,body"));
scDiv && dqSlt(":visible:not(html,body)").each(function() {
if ($(this).css("overflow-y") != "hidden" &&
this.clientHeight > 0.5 * window.innerHeight &&
this.scrollHeight > this.clientHeight + 0.5 * window.innerHeight) {
visDiv = $(this);
return false
}
});
return visDiv;
}
function autoScrollBy(scrollBy_Ju, speed = 0, scDiv = null) {
visibleDiv(scDiv).stop().animate({
scrollTop: "+=" + scrollBy_Ju + "px"
}, speed, "linear");
}
function autoScrollTo(scrollTo_Ju, speed = 0) {
visibleDiv().stop().animate({
scrollTop: scrollTo_Ju
}, speed, "linear");
}
function downloadTxt(filename, textContent) {
var objectURL = URL.createObjectURL(new Blob([textContent], {
type: "text/plain;charset=utf-8"
}));
$('<a>').attr({
href: objectURL,
download: filename,
style: 'display:none!important;'
}).appendTo('body')[0].click();
setTimeout(function() {
URL.revokeObjectURL(objectURL);
}, 2000);
}
function fontInterFn() {
dqSlt(":visible:not([JqMA-css-textBig],.JqMA-inner-pic *,.JqMA-btn-all,#pagetual-picker *)").filter(function() {
var textLen = $(this).clone().children().remove().end().text()
.replace(/\s+/g, "").length;
if (textLen > 0 && (outerSz === 0 || this.clientWidth > outerSz)) {
if (!oldFont && textLen > 50) {
oldFont = parseInt($(this).css("font-size").replace("px", ""));
}
return true;
}
return false;
}).attr("JqMA-css-textBig", 1).each(function() {
this.style.cssText += "font-size:" + widthN + "px!important;";
});
var _scale = oldFont ? parseInt(widthN / oldFont * 1000) / 1000 : 1;
dqSlt("[JqMA-css-textBig]").find("em:not([JqMA-css-textBig]),img").not("[JqMA-css-textImg]").filter(function() {
return $(this).is("img,[JqMA-mark-backImg]") &&
this.clientWidth < 0.1 * window.innerWidth;
}).attr("JqMA-css-textImg", 1).each(function() {
this.style.cssText += "transform: scale(" + _scale + ") !important;" +
"-webkit-transform: scale(" + _scale + ") !important;" +
"-moz-transform: scale(" + _scale + ") !important;" +
"margin: 0 " + (_scale * 9 - 9) + "px !important;"
});
}
function removeTextClass() {
dqSlt(".JqMA-btn-width").text(widthN ? widthN : "W");
dqSlt("[JqMA-css-textBig]").removeAttr("JqMA-css-textBig").each(function() {
this.style.cssText += "font-size:inherit!important";
});
dqSlt("[JqMA-css-textImg]").removeAttr("JqMA-css-textImg").each(function() {
this.style.cssText += "transform: scale(1) !important;" +
"-webkit-transform: scale(1) !important;" +
"-moz-transform: scale(1) !important;" +
"margin: 0 !important;";
});
}
var widthN = getValLoc("widthN", 0),
oldFont;
dqSlt("html").on('click', '.JqMA-btn-width', function() {
var inputNum = window.prompt("请输入字体大小:", widthN ? widthN : 30);
widthN = Number(inputNum) ? Number(inputNum) : 0;
removeTextClass();
widthN && fontInterFn();
setValLoc("widthN", widthN);
}).slideScreen('.JqMA-btn-width', function(event) {
if (!widthN) return;
var [offsetX, offsetY] = getTouchSite(event.target, event);
if (offsetY > 30) {
widthN -= 1;
} else if (offsetY < -30 || offsetX > 40) {
widthN += 1;
}
removeTextClass();
fontInterFn();
setValLoc("widthN", widthN);
});
dqSlt("html").longPress('.JqMA-btn-width', function() {
var innerWordLen = dqSlt(".JqMA-inner-word").length;
dqSlt('.JqMA-btn-width').each(function() {
this.style.setProperty("color", innerWordLen ? null : "green", "important");
});
if (innerWordLen) {
dqSlt(".JqMA-inner-word").remove();
window.speechSynthesis.cancel();
} else {
var allStr = "";
dqSlt(":visible").each(function() {
var addStr = $(this).clone().children().remove().end().text();
if (addStr.replace(/[一-鿯]/g, "aa").replace(/[^A-Za-z]/g, "").length > 8) {
addStr += "<br><br>";
}
allStr += addStr + " ";
});
allStr = allStr.replace(/\s+/g, " ");
$(document.querySelector("body")).prepend($("<p>").attr({
class: "JqMA-inner-word JqMA-inner-all"
}).html(allStr));
if (window.confirm('是否朗读?(插件浏览器有效,取消进入下载)')) {
window.speechSynthesis.cancel();
var allStrlist = allStr.replace(/<br><br>/g, "\n").split(/([\s\S]{100,400}?[…~;—。!?!?]|[\s\S]{400}[,,\s])/);
for (let i = 0; i < allStrlist.length; i++) {
if (allStrlist[i].length > 0) {
var utterThis = new SpeechSynthesisUtterance(allStrlist[i]);
window.speechSynthesis.speak(utterThis);
}
}
} else {
downloadTxt(document.title.replace(/[\/:*?""<>|]+/g, " ").replace(/^\s+|\s+$/g, "") + ".txt", allStr.replace(/<br><br>/g, "\n\n"));
}
}
});
function picSizeOut(_this, picwh_2 = null) {
let natureW = _this.naturalWidth,
natureH = _this.naturalHeight;
if (!picwh_2) {
picwh_2 = picwh;
}
return Math.min(natureW, natureH) >= picwh_2 &&
natureW / natureH <= 6;
}
function formatStr(_url) {
if (typeof _url === "string") {
return _url.replace(/^\s+|\s+$/g, "").replace(/&/g, "&").replace(/\\u002F/g, "/").replace(/\\[/]/g, "/");
} else {
return "";
}
}
function decodeStr(_url) {
let newI = _url;
if (/^https?%/.test(newI)) {
try {
newI = decodeURIComponent(newI);
} catch (error) {
console.log(error);
}
}
return newI;
}
function delHttp(_url) {
let newI = [];
if (/^(?!blob:|data:).+https?[:%]/.test(_url)) {
let _urlSpl = _url.split(/.(?=https?[:%])/);
for (let i = 1; i < _urlSpl.length; i++) {
if (!/\.html(&|$)/.test(_urlSpl[i])) {
newI.push(decodeStr(_urlSpl[i].replace(/^([^?]+?)&.*$/, "$1")));
}
}
}
return newI;
}
var preMatches = [];
function xiuTan() {
if (!document.querySelector(".JqMA-btn-hrefAll")) {
var spanStyle = "margin-left: auto!important; height: 6px!important; line-height: 6px!important;color:red!important;text-align:center!important;position:static!important;";
var spanStr = '<span class="JqMA-btn-all" style="' + spanStyle + '">——</span>';
$(document.querySelector("html")).append($("<p>").attr({
class: "JqMA-btn-all JqMA-btn-hrefAll",
style: "background: none!important; overflow: scroll!important; height: auto!important; max-height: 11vh!important; width: 40vw!important; bottom: 4px!important; right: 0!important;"
}).append(spanStr).append(spanStr));
}
var pageSource = "";
dqSlt("html").each(function() {
pageSource += this.outerHTML;
});
let videoList = [];
dqSlt("iframe").each(function() {
let srcDomain;
try {
srcDomain = new URL(this.src).origin;
} catch (error) {
console.log(error);
}
if (srcDomain && srcDomain != window.location.origin) {
videoList.push(this.src);
}
});
dqSlt("video").each(function() {
videoList.push(this.currentSrc);
});
var regex = /https?[:%][^""<>\s]*?\.(avi|mp4|mov|m4v|m3u8|wmv|flv|f4v|webm)([?!/&%][^""<>\s]*?)?(?=[""<>\s一-鿯]|https?[:%]|$)/gi;
var matches = pageSource.replace(/"|['']/g, '"').match(regex);
if (matches) videoList = videoList.concat(matches);
window.performance.getEntries().forEach(function(entry) {
if (/\.(avi|m3u8|mp4|mov|m4v|wmv|flv|f4v|webm)([?!/&%]|$)/.test(entry.name)) {
videoList.push(entry.name);
}
});
videoList = Array.from(new Set(videoList));
var newI,
newMatches = [];
for (let i = 0; i < videoList.length; i++) {
newI = formatStr(videoList[i]);
if (!newI.replace(/[\s/]/g, "").length || /^blob:|^data:/.test(newI)) continue;
newMatches.push(newI);
let delHtList = delHttp(newI);
if (delHtList.length) newMatches = newMatches.concat(delHtList);
}
for (let i = 0; i < newMatches.length; i++) {
newI = addLocation(decodeStr(newMatches[i]));
if (preMatches.indexOf(newI) > -1) continue;
preMatches.push(newI);
$(document.querySelector(".JqMA-btn-hrefAll span")).after($("<a>").attr({
href: newI,
class: "JqMA-btn-all JqMA-btn-href",
style: "text-align:left!important;position:static!important;width: 40vw!important;"
}).text(newI.replace(/\/(?=$|\?)/g, "").replace(/^[^?]*[/]/, "").replace(/(?<=[^?/.]{9})[^?/.]+/, "")));
}
}
function getMinOuter(_this) {
return Math.min(_this.clientWidth, _this.clientHeight);
}
dqSlt("html").on('click', ".JqMA-btn-outerSz", function() {
dqSlt(".JqMA-btn-all").each(function() {
this.style.setProperty("display", "none", "important");
});
setTimeout(function() {
dqSlt("body").on("click.tempClickFunc", function(event) {
event.preventDefault();
dqSlt("body").off("click.tempClickFunc");
dqSlt(".JqMA-btn-all").each(function() {
this.style.setProperty("display", "block", "important");
});
let _this = $(event.target);
let _targetW = (_this.attr("img-outerWH") ? _this.attr("img-outerWH") : getMinOuter(_this[0])) - 10;
let inputNum = window.prompt("请输入过滤尺寸:", parseInt(_targetW));
if (Number(inputNum) || inputNum === "0") {
outerSz = Number(inputNum);
if (outerSz > 0 && outerSz < 40) outerSz = 40;
outerSz_run();
}
});
}, 100);
}).slideScreen('.JqMA-btn-outerSz', function(event) {
var [offsetX, offsetY] = getTouchSite(event.target, event);
if (offsetY > 30) {
if (outerSz < 50 && outerSz > 10) {
outerSz = 10;
} else {
outerSz -= 40;
}
} else if (offsetY < -30 || offsetX > 40) {
if (outerSz === 0) {
outerSz = 10;
} else if (outerSz === 10) {
outerSz = 40;
} else {
outerSz += 40;
}
}
outerSz_run();
});
function outerSz_run() {
if (outerSz < 0) outerSz = 0;
if (picZ) {
var _scrollTop = getScrollTop();
removePicClass();
imgInterFn();
setTimeout(function() {
autoScrollTo(_scrollTop);
}, 400);
}
if (widthN) {
removeTextClass();
fontInterFn();
}
dqSlt(".JqMA-btn-outerSz").text(outerSz);
setValLoc("outerSz", outerSz);
}
dqSlt("html").on('click', ".JqMA-btn-picwh", function() {
dqSlt(".JqMA-btn-all").each(function() {
this.style.setProperty("display", "none", "important");
});
setTimeout(function() {
dqSlt("body").on("click.tempClickFunc", function(event) {
event.preventDefault();
dqSlt("body").off("click.tempClickFunc");
dqSlt(".JqMA-btn-all").each(function() {
this.style.setProperty("display", "block", "important");
});
var _target = $(event.target);
if (_target.is("img")) {
var _picwh = Math.min(_target[0].naturalWidth, _target[0].naturalHeight) + 10;
}
var inputNum = window.prompt("请输入过滤尺寸:", _picwh ? _picwh : 50);
if (Number(inputNum)) {
picwh = Number(inputNum);
picImgFilter();
}
});
}, 100);
}).slideScreen('.JqMA-btn-picwh', function(event) {
var [offsetX, offsetY] = getTouchSite(event.target, event);
if (offsetY > 30) {
picwh -= 50;
} else if (offsetY < -30 || offsetX > 40) {
picwh += 50;
}
picImgFilter();
});
dqSlt("html").longPress('.JqMA-btn-picwh', function() {
DSImg = DSImg ? 0 : 1;
dqSlt(".JqMA-btn-picwh").each(function() {
this.style.setProperty("color", DSImg ? "green" : null, "important");
});
if (picZ) {
var _scrollTop = getScrollTop();
removePicClass();
imgInterFn();
setTimeout(function() {
autoScrollTo(_scrollTop);
}, 400);
}
if (DSImg) {
DSImgData[locHost()] = DSImg;
} else {
delete DSImgData[locHost()];
}
GM_setValue("DSImgData", DSImgData);
});
function picImgFilter() {
if (picwh < 50) picwh = 50;
if (picZ) {
dqSlt(".JqMA-inner-pic > a").addClass("JqMA-css-smallPic");
dqSlt(".JqMA-inner-pic .JqMA-mark-imgLoaded").each(function() {
if (picSizeOut(this)) {
$(this).nextAll("a:lt(2)").add(this).removeClass("JqMA-css-smallPic");
} else {
$(this).addClass("JqMA-css-smallPic");
}
});
}
dqSlt(".JqMA-btn-picwh").text(picwh);
setValLoc("picwh", picwh);
}
var picZ = getValLoc("picZ", 0);
dqSlt("html").on('click', ".JqMA-btn-pic", function() {
picZ = picZ ? 0 : 1;
dqSlt(".JqMA-btn-pic").each(function() {
this.style.setProperty("color", picZ ? "green" : null, "important");
});
if (picZ) {
imgInterFn();
} else {
removePicClass();
}
setValLoc("picZ", picZ);
}).slideScreen('.JqMA-btn-pic', function() {
var _scrollTop = getScrollTop();
dqSlt(".JqMA-inner-pic").attr("style", "display:none !important;");
autoScrollTo(0);
let i = 0,
_timeout = setInterval(function() {
autoScrollBy(window.innerHeight * 3, 200);
i++;
if (visibleDiv().prop('scrollHeight') - getScrollTop() <= 1.1 * window.innerHeight) {
clearInterval(_timeout);
setTimeout(function() {
if (picZ) {
removePicClass();
imgInterFn();
}
setTimeout(function() {
autoScrollTo(_scrollTop);
}, 400);
}, 400);
}
}, 205);
});
function removePicClass() {
dqSlt("[JqMA-mark-picSlt]").removeAttr("JqMA-mark-picSlt");
dqSlt(".JqMA-inner-pic").remove();
preImgArr = new Set();
}
function addLocation(_href) {
try {
return new URL(_href, window.location.origin).href;
} catch (error) {
return _href;
}
}
function getImgList(dataObj, _img, findA, aStr) {
let imgList = [];
dataObj.forEach(function(i) {
i = formatStr(i);
if (!i.replace(/[\s/]/g, "").length) return;
i = addLocation(decodeStr(i));
if (!preImgArr.has(i)) {
preImgArr.add(i);
imgList.push($("<img>").attr({
src: i,
loading: "lazy",
width: "300",
height: "100",
"img-outerWH": _img ? getMinOuter(_img[0]) : 40
}));
}
});
if (findA && imgList.length) {
imgList = imgList.concat(findAFunc(_img, aStr));
}
return imgList;
}
function findAFunc(_img, aStr) {
var imgList = [],
_newA = $(aStr),
_a = _img.closest("a"),
_img_2 = _img;
for (let i = 0; i < 3; i++) {
if (_a.length || _img_2.is("body")) break;
_a = _img_2.siblings("a[href]:first");
if (_a.length) break;
_a = _img_2.siblings().find("a[href]:first");
_img_2 = _img_2.parent();
}
if (_a.attr("href") && !/^javascript:|^#$/.test(_a.attr("href"))) {
_newA.attr("href", _a.attr("href"));
} else {
if (_a.length) {
_a.children(":not(a)").length || _a.append('<p style="display:none!important;">');
_a = _a.children(":not(a):first");
} else {
_a = _img;
}
_newA.on("click", function() {
_a.trigger("click");
});
}
var _element = _img[0];
var _newA2 = $(aStr).on("click", function() {
pageX.unshift($(this).prevAll("img:first")[0]);
_element.scrollIntoView({
"block": "center"
});
});
imgList.push(_newA);
imgList.push(_newA2.text(_img ? getMinOuter(_img[0]) : ""));
return imgList;
}
var preImgArr = new Set();
var imgRegex_1 = /https?[:%][^""<>\s]*?\.(xbm|tif|pjp|jpg|jpeg|tiff|gif|jfif|webp|png|bmp|pjpeg|avif)([?!/&%][^""<>\s]*?)?(?=[""<>\s一-鿯]|https?[:%]|$)/gi
var imgRegex_2 = /((?<=[""])[a-z]*[/]|https?[:%])[^""<>\s]*?\.(xbm|tif|pjp|jpg|jpeg|tiff|gif|jfif|webp|png|bmp|pjpeg|avif)([?!/&%][^""<>\s]*?)?(?=[""<>\s一-鿯]|https?[:%]|$)/gi
var imgRegex_3 = /(?<=data-src=[""])[^""]*?(?=[""])|((?<=[""])[a-z]*[/]|https?[:%])[^""<>\s]*?\.(xbm|tif|pjp|jpg|jpeg|tiff|gif|jfif|webp|png|bmp|pjpeg|avif)([?!/&%][^""<>\s]*?)?(?=[""<>\s一-鿯]|https?[:%]|$)/gi
function imgInterFn() {
if (!dqSlt(".JqMA-inner-pic").length) {
$(document.querySelector("body")).prepend($("<p>").attr({
class: "JqMA-inner-pic JqMA-inner-all"
}).append('<p class="JqMA-mark-pageNext JqMA-mark-pageNext_0 JqMA-mark-pageNum">可见元素</p>')
.append('<p class="JqMA-mark-pageNext JqMA-mark-pageNext_1 JqMA-mark-pageNum">深度搜索</p>')
.append('<p class="JqMA-mark-pageNext JqMA-mark-pageNext_2 JqMA-mark-pageNum">文字链接</p>'));
}
var pageNext_0 = $(document.querySelector(".JqMA-mark-pageNext_0")),
pageNext_1 = $(document.querySelector(".JqMA-mark-pageNext_1")),
pageNext_2 = $(document.querySelector(".JqMA-mark-pageNext_2")),
aStr = '<a class="JqMA-css-smallPic" style="' + (Dhide ? "height:0!important;border:0!important;" : "") + '">';
dqSlt("a:not(:has(img)),img,video,[JqMA-mark-backImg],.pagetual_pageBar")
.not("[JqMA-mark-picSlt],.JqMA-inner-pic *")
.each(function() {
if ($(this).is(".pagetual_pageBar")) {
!pageNext_1.prev().is(".JqMA-mark-pageNext") && pageNext_1.before($('<p class="JqMA-mark-pageNext">'));
DSImg && !pageNext_2.prev().is(".JqMA-mark-pageNext") && pageNext_2.before($('<p class="JqMA-mark-pageNext">'));
return true;
}
var _img = $(this),
dataObj = [],
imgArr = [],
aImg = $("<img>");
if (outerSz === 0 || getMinOuter(this) > outerSz) {
aImg.attr({
loading: "lazy",
width: "300",
height: "100",
"img-outerWH": getMinOuter(_img[0])
});
if (_img.is("img")) {
aImg.attr("src", this.currentSrc);
_img.on('load', function() {
if (!aImg.is("[JqMA-mark-imgHD]") && aImg.attr("src") != _img[0].currentSrc) {
aImg.attr("src", _img[0].currentSrc);
}
});
} else if (_img.is("video")) {
aImg.attr("src", this.poster);
} else if (_img.is("[JqMA-mark-backImg]")) {
aImg.attr("src", _img.css("background-image").split(/[""]/)[1]);
}
if (aImg.attr("src")) {
pageNext_1.before(aImg);
let aList = findAFunc(_img, aStr);
for (let i = 0; i < aList.length; i++) {
pageNext_1.before(aList[i]);
}
}
if (DSImg) {
var _imgHtml = "";
if (_img.is("a img")) _imgHtml = _img.closest("a").clone().removeAttr("style").empty().prop("outerHTML");
_imgHtml += _img.clone().removeAttr("src poster style").empty().prop("outerHTML");
let _isp;
if (_img.is("img")) {
_isp = _imgHtml.replace(/"|['']/g, '"').match(imgRegex_3);
} else {
_isp = _imgHtml.replace(/"|['']/g, '"').match(imgRegex_2);
}
if (_isp) {
imgArr = getImgList([_isp[0]], _img, 1, aStr);
if (imgArr.length) {
for (let i = 0; i < imgArr.length; i++) {
pageNext_2.before($(imgArr[i]));
}
}
}
}
}
if (_img.is("a:not([JqMA-mark-backImg])") || imgArr.length || aImg.attr("src")) {
_img.attr("JqMA-mark-picSlt", 1);
}
});
if (DSImg) {
var _text = dqSlt("body > :visible").text().replace(/"|['']/g, '"').match(imgRegex_1);
if (_text) {
_text = getImgList(_text, 0, 0, aStr);
_text.length && $(document.querySelector(".JqMA-inner-pic")).append(_text);
}
}
picImgCount(pageNext_0, pageNext_1, pageNext_2);
dqSlt(".JqMA-inner-pic img:not(.JqMA-mark-preAdd)").addClass("JqMA-mark-preAdd").on("load error", function() {
picImgCount(pageNext_0, pageNext_1, pageNext_2);
var oldNatureH = this.naturalHeight,
oldNatureW = this.naturalWidth;
if (Math.min(oldNatureW, oldNatureH) < 600) {
var thisSrcList = picHD(this.currentSrc),
_this = $(this),
promiseArray = [];
for (let i = 0; i < thisSrcList.length; i++) {
promiseArray.push(checkImgExists(thisSrcList[i]).catch(err => {
console.log(err)
}));
}
Promise.all(promiseArray).then(function(data) {
for (let i = 0; i < data.length; i++) {
let resH = data[i];
if (resH.naturalHeight > oldNatureH || resH.naturalWidth > oldNatureW) {
_this.attr({
src: resH.src,
"JqMA-mark-imgHD": 1
});
return;
}
}
});
}
if (picSizeOut(this, 50)) {
$(this).addClass("JqMA-mark-imgLoaded").nextAll("a:eq(0)").text(Math.min(oldNatureW, oldNatureH));
}
if (picSizeOut(this)) {
$(this).nextAll("a:lt(2)").add(this).removeClass("JqMA-css-smallPic");
} else {
$(this).attr({
style: Dhide ? "height: 0!important; border: 4px solid gray!important;" : null
}).addClass("JqMA-css-smallPic");
}
});
}
var picImgTime;
function picImgCount(pageNext_0, pageNext_1, pageNext_2) {
clearTimeout(picImgTime);
picImgTime = setTimeout(function() {
let picImgLen = dqSlt(".JqMA-inner-pic img:not(.JqMA-css-smallPic)").length,
keJian_Img = pageNext_1.prevAll("img:not(.JqMA-css-smallPic)"),
search_len = pageNext_2.prevAll("img:not(.JqMA-css-smallPic)").length;
let srcNum = new Set();
keJian_Img.each(function() {
srcNum.add(this.src);
});
pageNext_0.html(`可见:${srcNum.size} / ${keJian_Img.length} <a id="JqMA-mark-pageNext_1">深度</a>:${search_len - keJian_Img.length} <a id="JqMA-mark-pageNext_2">文字</a>:${picImgLen - search_len}`);
pageNext_1.text(`过滤尺寸:${outerSz} 深度搜索`);
}, 400);
}
function picHD(oldSrc) {
var thisSrc = oldSrc,
thisSrcList = [];
if (picReplace.indexOf("`") != -1) {
let numberToRe = /^@/.test(picReplace) ? 1 : 0,
picRepArr = picReplace.replace(/^@/, "").split("`");
for (let i = 0; i < parseInt(picRepArr.length / 2); i++) {
thisSrc = thisSrc.replace(numberToRe ? new RegExp(picRepArr[2 * i].replace(/(?<![{])\d(?![}])/g, "[0-9]")) : picRepArr[2 * i], picRepArr[2 * i + 1]);
}
thisSrcList.push(thisSrc);
}
thisSrcList.push(oldSrc.replace(/-\d{2,4}x\d{2,4}(?=[.-])/, ""));
thisSrcList.push(oldSrc.replace(/^(?=data:)(.+?)[^A-Za-z0-9+/=>;]+$/, "$1"));
let delHtList = delHttp(oldSrc);
if (delHtList.length) thisSrcList = thisSrcList.concat(delHtList);
if (!/.https?[:%]/.test(oldSrc)) {
thisSrcList.push(oldSrc.replace(/^([^?]+?)&.*$/, "$1"));
}
var newSrcList = [];
for (let i = 0; i < thisSrcList.length; i++) {
thisSrc = thisSrcList[i];
if (thisSrc != oldSrc) {
newSrcList.push(thisSrc);
}
}
return newSrcList;
}
var pageX = [];
dqSlt("html").on('click', '.JqMA-btn-down', function() {
if (pageX.length) {
pageX = Array.from(new Set(pageX));
if (typeof pageX[0] === "number") {
autoScrollTo(pageX[0]);
} else {
pageX[0].scrollIntoView({
"block": "center"
});
}
pageX.splice(0, 1);
}
}).slideScreen('.JqMA-btn-down', function(event) {
pageX.unshift(getScrollTop());
var [offsetX, offsetY] = getTouchSite(event.target, event);
if (offsetY > 30) {
if (Dtransform) {
autoScrollTo(0.5 * window.innerHeight);
} else {
autoScrollTo(0);
}
} else if (offsetY < -30 || offsetX > 40) {
var toHs = [];
$("body > :visible").each(function() {
var toH = -0.5 * window.innerHeight + this.clientHeight +
$(this).offset().top - $(window).scrollTop();
toHs.push(toH);
});
if (!scrollDiv && toHs.length) {
toHs.sort(function(a, b) {
return b - a;
});
autoScrollBy(toHs[0]);
} else {
autoScrollBy(1000 * window.innerHeight);
}
}
});
dqSlt("html").longPress('.JqMA-btn-down', function() {
var inputNum = window.prompt("是否保存滚动位置?(取消关闭)", parseInt(getScrollTop()));
if (inputNum === null) {
setValLoc("nextScrollTop", 0);
} else {
setValLoc("nextScrollTop", Number(inputNum));
}
});
function delHide() {
dqSlt(".JqMA-btn-all").each(function() {
if ($(this).is(".JqMA-btn-del")) {
this.style.cssText += "opacity:" + (Dhide ? "0.5" : "1") + "!important;";
} else {
this.style.cssText += "display:" + (Dhide ? "none" : "block") + "!important;";
}
});
if (picZ) {
dqSlt(".JqMA-inner-pic > a").each(function() {
this.style.cssText = Dhide ? "height: 0!important; border: 0!important;" : "";
});
dqSlt(".JqMA-inner-pic > img.JqMA-css-smallPic").each(function() {
this.style.cssText = Dhide ? "height: 0!important; border: 4px solid gray!important;" : "";
});
}
}
dqSlt("html").on('click', '.JqMA-btn-del', function() {
Dhide = Dhide ? 0 : 1;
delHide();
setValLoc("Dhide", Dhide);
}).slideScreen('.JqMA-btn-del', function() {
document.querySelector("#pagetual-sideController #loadNow").dispatchEvent(new MouseEvent('click'));
});
var nextScrollTop = getValLoc("nextScrollTop", 0);
dqSlt("html").longPress('.JqMA-btn-del', function() {
var newHref;
if (/[^a-z]page[=/]\d+(?=$|&)/.test(location.href)) {
openHref(getNextPage(location.href));
return;
} else if (/[/_\-]\d+(\.html)?$/.test(location.href)) {
newHref = getNextPage(location.href);
}
$(dqSlt("a").get().reverse()).each(function() {
if (/^\s*2\s*$/.test($(this).text()) &&
/[^a-z]page[=/]\d+(?=$|&)/.test(this.href)) {
if (openBlank) {
window.open(this.href);
} else {
location.href = this.href;
}
return false;
} else if (/^\s*(>|次のページ|下.?[章页]|下[一—].)\s*$|^\s*next\s*(page\s*)?$/i.test($(this).text())) {
var _a = $(this);
_a.children(":not(a)").length || _a.append('<p style="display:none!important;">');
_a.children(":not(a):first").trigger("click");
return false;
} else if (newHref && this.href === newHref) {
openHref(newHref);
return false;
}
});
});
function getNextPage(twoHref) {
var hrefSplit = /[^a-z]page[=/]/.test(twoHref) ? twoHref.split(/(?<=[^a-z]page)([=/])/) : twoHref.split(/([/_\-])(?=\d+(?:\.html)?$)/);
var pNumber = Number(hrefSplit[2].split(/[^\d]/)[0]) + 1;
var newHref = hrefSplit[0] + hrefSplit[1] + pNumber + hrefSplit[2].replace(/^\d+/, "");
return newHref;
}
function openHref(newHref) {
if (openBlank) {
window.open(newHref);
} else {
location.href = newHref;
}
}
function aOpenBlank() {
dqSlt("a:not([JqMA-mark-blank])").attr("JqMA-mark-blank", 1).filter(function() {
return !/^javascript:|^#$/.test(this.href);
}).attr("target", "_blank");
}
var openBlank = getValLoc("openBlank", 0),
preIframes = new Set();
dqSlt("html").on('click', '.JqMA-btn-blank', function() {
openBlank = openBlank ? 0 : 1;
dqSlt(".JqMA-btn-blank").each(function() {
this.style.setProperty("color", openBlank ? "green" : null, "important");
});
if (openBlank) {
aOpenBlank();
} else {
dqSlt("[JqMA-mark-blank]").removeAttr("JqMA-mark-blank").attr("target", null);
}
setValLoc("openBlank", openBlank);
}).slideScreen('.JqMA-btn-blank', function() {
dqSlt(".JqMA-btn-all").each(function() {
this.style.setProperty("display", "none", "important");
});
setTimeout(function() {
var firstTarget;
dqSlt("body").on("click.tempClickFunc", function(event) {
event.preventDefault();
if (!firstTarget) {
firstTarget = event.target;
return;
}
dqSlt("body").off("click.tempClickFunc");
dqSlt(".JqMA-btn-all").each(function() {
this.style.setProperty("display", "block", "important");
});
var isInput = $(firstTarget).closest("a").length ? 0 : 1,
first_aCss;
firstTarget = $(firstTarget).closest(isInput ? "input" : "a");
var lastTarget = $(event.target).closest(isInput ? "input" : "a");
if (firstTarget.length && lastTarget.length) {
dqSlt(isInput ? "input" : "a").each(function() {
if ($(this).is(firstTarget)) first_aCss = 1;
if (first_aCss && this.href && !preIframes.has(this.href)) {
preIframes.add(this.href);
$(document.querySelector("body")).append($("<iframe>").attr({
src: this.href,
scrolling: "no",
style: "box-sizing: border-box !important; overflow: hidden !important; width: 100% !important; min-height: 150vh!important;"
}).on("load", function() {
$(this).before($('<p class="pagetual_pageBar">'));
$(this).contents().length && this.replaceWith(...$(this).contents().find("body"));
}));
}
first_aCss && isInput && $(this).prop("checked", true);
if ($(this).is(lastTarget)) return false;
});
} else {
alert("请点击链接或复选框!");
}
if (window.confirm("是否复制选择器?")) copyToClipboard(getElementSelector(event.target));
});
}, 100);
});
dqSlt("html").longPress('.JqMA-btn-blank', function() {
document.querySelector("html").requestFullscreen();
screen.orientation.lock = hengPin;
screen.orientation.lock('landscape');
});
var Dscroll = 0,
timeDown,
animateTime = 800;
dqSlt("html").on('click', '.JqMA-btn-Ju', function() {
Dscroll = Dscroll ? 0 : 1;
clearInterval(timeDown);
dqSlt(".JqMA-btn-Ju").each(function() {
this.style.setProperty("color", Dscroll ? "green" : null, "important");
});
if (Dscroll) {
timeDown = setInterval(function() {
let scrollNum = window.innerHeight * 0.00006 * animateTime;
autoScrollBy(direction * scrollJu * scrollNum, smoothScroll ? 0 : animateTime);
}, animateTime + 5);
} else {
dqSlt("html,body").stop();
visibleDiv().stop();
}
GM_setValue("scrollJu", scrollJu);
}).slideScreen('.JqMA-btn-Ju', function(event) {
var [offsetX, offsetY] = getTouchSite(event.target, event);
if (offsetY > 30) {
scrollJu -= 1;
} else if (offsetY < -30 || offsetX > 40) {
scrollJu += 1;
}
scrollJu = Math.max(scrollJu, 0);
dqSlt(".JqMA-btn-Ju").text((smoothScroll ? "`" : "") + scrollJu);
GM_setValue("scrollJu", scrollJu);
});
dqSlt("html").longPress('.JqMA-btn-Ju', function(event) {
var inputNum = window.prompt("请输入滚动速度(以`开头表间隔):", (smoothScroll ? "`" : "") + scrollJu);
smoothScroll = inputNum.startsWith("`") ? 1 : 0;
if (Number(inputNum.replace("`", ""))) {
scrollJu = Number(inputNum.replace("`", ""));
scrollJu = Math.max(scrollJu, 0);
dqSlt(".JqMA-btn-Ju").text((smoothScroll ? "`" : "") + scrollJu);
GM_setValue("scrollJu", scrollJu);
GM_setValue("smoothScroll", smoothScroll);
}
});
})(dom.jQuery);
},
10);
}