// ==UserScript==
// @name 手机助手
// @namespace http://tampermonkey.net/
// @version 9.500.20.36
// @description 自动滚动,嗅探图片、视频,字体放大,去除广告浮动
// @author You
// @match *://*/*
// @run-at document-start
// @grant GM_registerMenuCommand
// @grant GM_setValue
// @grant GM_getValue
// @license MIT
// ==/UserScript==
{
'use strict';
let hengPin = screen.orientation.lock;
(function() {
function isInIframe() {
try {
return window.self !== window.top;
} catch (e) {
return true;
}
}
if (isInIframe() || document.querySelector('.JqMA-btn-all')) {
return;
}
const currentDomain = window.location.hostname;
function docSltAll(selectPath) {
let doms = Array.from(document.querySelectorAll(selectPath));
document.querySelectorAll('iframe').forEach(function(iframe) {
let contentDocument;
try {
contentDocument = iframe.contentDocument || iframe.contentWindow.document;
} catch (error) {
console.log(error);
}
if (contentDocument) {
doms.push(...Array.from(contentDocument.querySelectorAll(selectPath)));
}
});
return doms;
}
function simulateClick(element) {
try {
element.click();
} catch (error) {
element.dispatchEvent(new MouseEvent('click'));
}
}
function scrollToElement(element, options = {}) {
element.scrollIntoView(options);
setTimeout(function() {
element.scrollIntoView(options);
}, 300);
}
function createElement(tagName, attributes = {}, content = false) {
let element = document.createElement(tagName);
for (let attr in attributes) {
if (attributes.hasOwnProperty(attr)) {
element.setAttribute(attr, attributes[attr]);
}
}
if (content !== false) {
element.textContent = content;
}
return element;
}
function getDataValue(gValName, _default) {
let _data = GM_getValue(gValName, {});
const keys = Object.keys(_data);
if (keys.length > 50) {
delete _data[keys[0]];
GM_setValue(gValName, _data);
}
return [_data, _data[currentDomain] !== undefined ? _data[currentDomain] : _default];
}
let [txtToCData, txtToC] = getDataValue("txtToCData", "");
let [cssToCData, cssToC] = getDataValue("cssToCData", "");
let [clickNumData, clickNum] = getDataValue("clickNumData", 1);
GM_registerMenuCommand(`加载点击 ${clickNum}次 ${txtToC} ${cssToC}`, function() {
const _menu = prompt(`1、输入文本 ${txtToC}\n2、输入css选择器 ${cssToC}\n3、点击次数 ${clickNum}次`, 1);
if (_menu == "1") {
const _prot = prompt('页面加载点击 输入文本 分隔`', txtToC);
if (_prot === "") {
txtToC = "";
delete txtToCData[currentDomain];
} else if (_prot !== null) {
txtToC = _prot;
txtToCData[currentDomain] = _prot;
}
GM_setValue("txtToCData", txtToCData);
} else if (_menu == "2") {
const _prot = prompt('页面加载点击 输入css选择器 分隔`', cssToC);
if (_prot === "") {
cssToC = "";
delete cssToCData[currentDomain];
} else if (_prot !== null) {
cssToC = _prot;
cssToCData[currentDomain] = _prot;
}
GM_setValue("cssToCData", cssToCData);
} else if (_menu == "3") {
const _prot = prompt('页面加载点击 输入点击次数', clickNum);
if (_prot === "") {
clickNum = 1;
delete clickNumData[currentDomain];
} else if (_prot !== null) {
clickNum = Number(_prot);
clickNumData[currentDomain] = _prot;
}
GM_setValue("clickNumData", clickNumData);
}
});
function clickElementsWithTextsOrSelectors(_tToC, _cToC) {
if (_tToC.length) {
const texts = _tToC.split('`');
for (let i = 0; i < texts.length; i++) {
const elements = document.body.getElementsByTagName('*');
for (let j = 0; j < elements.length; j++) {
const element = elements[j];
if (element.textContent.includes(texts[i])) {
for (let k = 0; k < clickNum; k++) {
simulateClick(element);
}
}
}
}
}
if (_cToC.length) {
const selectors = _cToC.split('`');
for (let i = 0; i < selectors.length; i++) {
const elements = document.querySelectorAll(selectors[i]);
for (let j = 0; j < elements.length; j++) {
for (let k = 0; k < clickNum; k++) {
simulateClick(elements[j]);
}
}
}
}
}
function removeShadowRoot() {
let hasShadowRoot;
const divs = document.querySelectorAll('div');
for (let i = 0; i < divs.length; i++) {
let _this = divs[i];
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) {
let ImgObj = new Image();
ImgObj.src = imgurl;
ImgObj.onload = function(res) {
resolve(this);
}
ImgObj.onerror = function(err) {
reject(err)
}
});
}
function getTouchSite(_element, event) {
let rect = _element.getBoundingClientRect();
let offsetY = event.touches[0].clientY - rect.top - _element.offsetHeight / 2;
let offsetX = event.touches[0].clientX - rect.left - _element.offsetHeight / 2;
return [offsetX, offsetY, _element.offsetHeight];
}
function getSelector(element) {
let path = "",
index = 0;
while (index < 3 && element && element.nodeType == Node.ELEMENT_NODE) {
let 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).slice(0, 2).join(".");
}
path = selector + " > " + path;
element = element.parentNode;
index++;
}
return path.replace(/[> ]+$/, "");
}
function documentCopy(copyText) {
let _input = createElement('input', {
style: 'position:fixed!important;clip:rect(0 0 0 0)!important;top:10px!important;',
value: copyText
});
document.body.appendChild(_input);
_input.select();
document.execCommand('copy');
document.body.removeChild(_input);
}
function copyToClipboard(copyText) {
try {
navigator.clipboard.writeText(copyText).catch(() => {
documentCopy(copyText);
});
} catch (error) {
documentCopy(copyText);
}
}
let addCss = GM_getValue("addCss", "");
let hidePagetual = GM_getValue("hidePagetual", 0)
GM_registerMenuCommand(`1:隐藏按钮 2:${hidePagetual ? "显示" : "隐藏"}东方 3:添加css ${addCss}`, function() {
const element = document.querySelector(".JqMA-btn-del");
const isHide = window.getComputedStyle(element).display === "none";
let inputNum = window.prompt(`1:${isHide ? "显示" : "隐藏"}按钮 2:${hidePagetual ? "显示" : "隐藏"}东方按钮 3:添加css ${addCss}`, 1);
if (inputNum === "1") {
if (isHide) {
document.head.removeChild(hideAllBtn);
} else {
document.head.appendChild(hideAllBtn);
}
} else if (inputNum === "2") {
hidePagetual = hidePagetual ? 0 : 1;
GM_setValue("hidePagetual", hidePagetual);
location.reload(false);
} else if (inputNum === "3") {
inputNum = window.prompt("输入css内容:", addCss);
if (inputNum !== null) {
GM_setValue("addCss", inputNum);
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(currentDomain) ? changeData[currentDomain] : _default]
} else {
return false;
}
}
let html_style =
`* {
overflow-wrap: break-word!important;
scroll-behavior: auto!important;
} html,html > body {
min-height: 100vh!important;
}`;
let inner_style =
`.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-inner-all{
position: relative !important;
z-index: 2147483646 !important;
margin: 15vh 0 5vh 0!important;
border: 0 !important;
padding: 0 !important;
width: 100vw !important;
height: auto !important;
background: black !important;
display: block !important;
} .JqMA-inner-all,
.JqMA-inner-word *,
.JqMA-inner-pic * {
box-sizing: border-box !important;
border-radius: 0 !important;
float: none !important;
opacity: 1 !important;
visibility: visible !important;
filter: none!important;
-webkit-filter: none!important;
} .JqMA-inner-word,
.JqMA-inner-word > p {
color: #FEFEFE!important;
text-align: left!important;
font-size: calc(2.3vh + 2.3vw)!important;
text-indent: 0!important;
} .JqMA-inner-word > p {
width: 100%!important;
}
.JqMA-inner-pic {
text-align: center !important;
font: 0 "Fira Sans", sans-serif !important;
} .JqMA-inner-word *,
.JqMA-inner-pic *{
margin: 0 !important;
padding: 0 !important;
border: 0 !important;
position: static !important;
} .JqMA-inner-pic *::before,
.JqMA-inner-pic *::after {
display: none !important;
} .JqMA-inner-pic > img {
display: inline-block !important;
width: auto !important;
min-width: 12.5% !important;
max-width: 100% !important;
height: auto !important;
min-height: calc(4vh + 4vw)!important;
object-fit: contain !important;
background: gray !important;
} .JqMA-inner-pic > img.JqMA-css-smallPic {
max-width: 33.3%!important;
max-height: calc(11vh + 11vw)!important;
} .JqMA-inner-pic > *{
vertical-align: top !important;
overflow: hidden !important;
} .JqMA-inner-word a,
.JqMA-inner-pic a,
.JqMA-mark-pageNum {
background: none!important;
color: #FEFEFE!important;
height: calc(2.7vh + 2.7vw)!important;
font-size: calc(1.7vh + 1.7vw)!important;
line-height: 1.4!important;
text-align: center!important;
} .JqMA-mark-pageNum {
width: 100%!important;
} .JqMA-inner-word > a{
display: inline-block!important;
width: 100%!important;
} .JqMA-inner-pic > a {
display: inline-block!important;
width: 12.5%!important;
margin-left: -12.5%!important;
height: calc(4vh + 4vw)!important;
background: rgba(0,0,0,0.2)!important;
line-height: 1.1!important;
} .JqMA-inner-pic > p > a{
display: inline!important;
} .JqMA-btn-all {
overflow: hidden!important;
opacity: 1!important;
background: rgba(0,0,0,0.4)!important;
color: #FEFEFE!important;
display: none!important;
text-align: center!important;
text-indent: 0!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.2vh + 1.2vw)!important;
height: calc(3.2vh + 3.2vw)!important;
width: calc(3.2vh + 3.2vw)!important;
} html .JqMA-btn-del {
display: block!important;
opacity: 0.4!important;
}.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-inner-word,.JqMA-inner-word > p {
letter-spacing: normal !important;
line-height: normal !important;
}` + addCss;
if (hidePagetual) {
inner_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 getValLoc(gValName, _default) {
if (currentDomain == GM_getValue(gValName + "_locH")) {
return GM_getValue(gValName, _default);
} else {
return _default;
}
}
function setValLoc(gValName, value) {
GM_setValue(gValName, value);
GM_setValue(gValName + "_locH", currentDomain);
}
let scrollJu = Math.abs(GM_getValue("scrollJu", 5));
let [DSImgData, DSImg] = getDataValue("DSImgData", 1);
let minPicHD = GM_getValue("minPicHD", 500);
let minPicwh = GM_getValue("minPicwh", 100),
picwh = getValLoc("picwh", minPicwh);
let minOuterSz = GM_getValue("minOuterSz", 10),
outerSz = getValLoc("outerSz", minOuterSz);
let smoothScroll = GM_getValue("smoothScroll", 0);
let direction = 1;
function addInput(class1, value1, style1) {
document.documentElement.appendChild(createElement('p', {
class: "JqMA-btn-all " + class1
}, value1));
inner_style += ".JqMA-btn-all." + class1 + "{" + style1 + "!important;left: 0!important;}";
}
function addAllBtn() {
addInput('JqMA-btn-del', 'X', "top:calc(50vh - 1.6vh - 1.6vw)");
addInput('JqMA-btn-down', '♢', "top:calc(50vh - 4.8vh - 4.8vw)");
addInput('JqMA-btn-Ju', (smoothScroll ? "`" : "") + scrollJu, "top:calc(50vh - 8vh - 8vw)");
addInput('JqMA-btn-width', widthN ? widthN : "W", "top:calc(50vh - 11.2vh - 11.2vw)");
addInput('JqMA-btn-scrollDiv', 'O', "top:calc(50vh - 14.4vh - 14.4vw)");
addInput('JqMA-btn-transform', "T", "top:calc(50vh + 1.6vh + 1.6vw)");
addInput('JqMA-btn-blank ', 'B', "top:calc(50vh + 4.8vh + 4.8vw)");
addInput('JqMA-btn-pic', picwh, "top:calc(50vh + 8vh + 8vw)");
addInput('JqMA-btn-outerSz', outerSz, "top:calc(50vh + 11.2vh + 11.2vw)");
document.head.appendChild(createElement('style', false, html_style + inner_style));
openBlk && document.querySelector(".JqMA-btn-blank").style.setProperty("color", "green", "important");
DSImg && document.querySelector(".JqMA-btn-outerSz").style.setProperty("color", "green", "important");
Dtransform && document.querySelector(".JqMA-btn-transform").style.setProperty("color", "green", "important");
picZ && document.querySelector(".JqMA-btn-pic").style.setProperty("color", "green", "important");
Drotate && document.querySelector(".JqMA-btn-scrollDiv").style.setProperty("color", "green", "important");
delHide();
}
let Dhide = getValLoc("Dhide", 1);
let picAimgStyle = createElement("style", false);
setTimeout(function() {
if (Dtransform) {
applyClearStyle();
}
clickElementsWithTextsOrSelectors(txtToC, cssToC);
firstRun();
if (picZ && preImgArr[1].size < 9) {
scrollPicLoad();
}
document.addEventListener('touchend', function handler(event) {
if (Dscroll) {
Dscroll = 0;
scrollRun();
}
event.currentTarget.removeEventListener(event.type, handler);
});
}, 800);
let _timeTouch;
function touchRun() {
clearTimeout(_timeTouch);
_timeTouch = setTimeout(function() {
firstRun();
for (let i = 0; i < 20; i++) {
setTimeout(function() {
_timeTouch && clearTimeout(_timeTouch);
}, i * 200);
}
}, 300);
}
function htmlTouch(event) {
if (Dscroll && !pauseScroll) {
const _target = event.target;
if (!_target.matches(".JqMA-btn-Ju")) {
scrollRun();
if (!_target.matches(".JqMA-btn-down")) {
pauseScroll = true;
}
}
}
}
let oNextScroll;
function firstRun() {
if (!document.querySelector('.JqMA-btn-all')) {
addAllBtn();
}
Drotate && fullScreen();
widthN && fontInterFn();
picZ && imgInterFn();
openBlk && aOpenBlank();
!Dhide && xiuTan();
document.querySelector(".JqMA-inner-word") && innerWordAdd();
if (!oNextScroll && nextScrollTop) {
const element = visibleDiv([9, -9], true);
if (element) {
autoScrollTo(element, nextScrollTop);
oNextScroll = 1;
}
}
docSltAll("html:not([JqMA-mark-htmlFunc])").forEach(function(elet) {
elet.setAttribute('JqMA-mark-htmlFunc', true);
elet.addEventListener('click', function(event) {
const _target = event.target;
if (_target.matches("#JqMA-mark-pageNext_1,#JqMA-mark-pageNext_2")) {
pageX.unshift(visibleDiv([9, -9], true).scrollTop);
scrollToElement(document.querySelector("." + _target.id));
} else if (_target.matches("a,a *")) {
setTimeout(function() {
if (Dscroll) {
scrollRun();
pauseScroll = true;
}
}, 210);
} else if (!this.matches("html *") && !_target.matches(pointEle) && _target.offsetWidth > 0.45 * window.innerWidth) {
direction = event.clientY < window.innerHeight * 0.2 ? -1 : 1;
autoScrollBy(visibleDiv(direction > 0 ? [9] : [-9]), direction * (widthN && !picZ ? 0.9 : 0.45) * window.innerHeight);
}
if (nextScrollTop) {
autoScrollTo(visibleDiv([9, -9], true), nextScrollTop);
}
});
elet.addEventListener('touchstart', function(event) {
htmlTouch(event);
});
elet.addEventListener('touchmove', function(event) {
htmlTouch(event);
});
elet.addEventListener("touchend", function() {
touchRun();
stopPause();
});
});
}
let pauseScroll;
function stopPause() {
setTimeout(function() {
if (pauseScroll) {
pauseScroll = false;
Dscroll || scrollRun();
}
}, 200);
}
function onLongPress(element, callback, timeout = 600) {
let timer = null;
let touchLen = true;
element.addEventListener('touchstart', function(event) {
timer = setTimeout(function() {
if (touchLen) {
callback(event);
}
}, timeout);
setTimeout(function() {
touchLen = true;
}, timeout);
});
element.addEventListener('touchend', function() {
clearTimeout(timer);
});
element.addEventListener('touchmove', function(event) {
timer && clearTimeout(timer);
if (touchLen && event.touches.length > 1) {
touchLen = false;
}
});
}
function onSlideScreen(element, callback, timeout = 600) {
let timer = null;
element.addEventListener('touchmove', function(event) {
timer && clearTimeout(timer);
timer = setTimeout(function() {
callback(event);
}, timeout);
});
}
const pointEle = "textarea,input,video,button,select";
function btnScrollDivClick() {
let width = prompt("页面宽度:", Drotate_W);
if (width === null) {
Drotate = false;
document.exitFullscreen();
document.head.removeChild(fullBodyStyle);
} else {
Drotate_W = Number(width);
Drotate = true;
setValLoc("Drotate_W", Drotate_W);
fullScreen();
}
document.querySelector(".JqMA-btn-scrollDiv").style.setProperty("color", Drotate ? "green" : null, "important");
setValLoc("Drotate", Drotate);
}
let pageX = [];
let [widthNdata, widthN] = getDataValue("widthNdata", 0);
let [picZData, picZ] = getDataValue("picZData", 0);
let [openBlkData, openBlk] = getDataValue("openBlkData", 0);
let preIframes = new Set();
let Dscroll = getValLoc("Dscroll", 0);
let timeDown;
document.addEventListener('click', function(event) {
const eventClass = event.target.classList;
if (eventClass.contains('JqMA-btn-down')) {
btnDownClick();
} else if (eventClass.contains('JqMA-btn-scrollDiv')) {
btnScrollDivClick();
} else if (eventClass.contains('JqMA-btn-transform')) {
btnTransfClick();
} else if (eventClass.contains('JqMA-btn-width')) {
btnWidthClick();
} else if (eventClass.contains('JqMA-btn-outerSz')) {
btnOuterSzClick();
} else if (eventClass.contains('JqMA-btn-pic')) {
btnPicClick();
} else if (eventClass.contains('JqMA-btn-del')) {
btnDelClick();
} else if (eventClass.contains('JqMA-btn-blank')) {
btnBlankClick();
} else if (eventClass.contains('JqMA-btn-Ju')) {
btnJuClick();
}
});
let [DtransformData, Dtransform] = getDataValue("DtransformData", 0);
GM_registerMenuCommand(`去浮动:${Dtransform ? "开": '关'}`, function() {
btnTransfClick();
});
let hideAllBtn = createElement("style", false, `html .JqMA-btn-all {display:none!important;}`);
onSlideScreen(document, function(event) {
const eventClass = event.target.classList;
if (eventClass.contains('JqMA-btn-Ju')) {
let [offsetX, offsetY, thisHeight] = getTouchSite(event.target, event);
if (offsetY > thisHeight) {
scrollJu -= 1;
} else if (offsetY < -thisHeight || offsetX > thisHeight) {
scrollJu += 1;
} else {
btnJuClick();
return;
}
scrollJu = Math.max(scrollJu, 0);
document.querySelectorAll(".JqMA-btn-Ju").forEach(function(_this) {
_this.textContent = (smoothScroll ? "`" : "") + scrollJu;
});
GM_setValue("scrollJu", scrollJu);
} else if (eventClass.contains('JqMA-btn-blank')) {
let [offsetX, offsetY, thisHeight] = getTouchSite(event.target, event);
if (offsetY > thisHeight || offsetY < -thisHeight || offsetX > thisHeight) {
let firstTarget;
document.head.appendChild(hideAllBtn);
setTimeout(function() {
docSltAll("body:not(body *)").forEach(function(_this) {
_this.addEventListener('click', tempClickFunc);
});
function tempClickFunc(event) {
event.preventDefault();
if (!firstTarget) {
firstTarget = event.target;
return;
}
docSltAll("body").forEach(function(_this) {
_this.removeEventListener('click', tempClickFunc);
});
document.head.removeChild(hideAllBtn);
let isInput = firstTarget.matches("a") || firstTarget.closest("a") ? 0 : 1;
let aSelet = getSelector(event.target);
if (firstTarget === event.target) copyToClipboard(aSelet);
firstTarget = firstTarget.closest(isInput ? "input" : "a");
let lastTarget = event.target.closest(isInput ? "input" : "a");
if (firstTarget && lastTarget) {
let first_aCss;
aSelet = prompt("修改选择器:", aSelet);
docSltAll(aSelet).forEach(el => {
if (el === firstTarget) first_aCss = true;
if (first_aCss) {
if (isInput) {
el.checked = true;
} else if (el.href && !preIframes.has(el.href)) {
preIframes.add(el.href);
let iframe = createElement("iframe", {
src: el.href,
scrolling: "no",
sandbox: 'allow-scripts allow-same-origin',
style: "box-sizing: border-box !important; overflow: hidden !important; width: 100% !important; min-height: 150vh!important;"
});
iframe.onload = function() {
let _this = this;
setTimeout(function() {
if (_this.contentDocument.body.childNodes.length) {
_this.parentNode.replaceChild(_this.contentDocument.body, _this);
}
}, 1000);
};
document.body.appendChild(createElement('p', {
class: "pagetual_pageBar"
}));
document.body.appendChild(iframe);
}
if (el === lastTarget) first_aCss = false;
}
});
} else {
alert("请点击链接或复选框!");
}
}
}, 100);
} else {
btnBlankClick();
}
} else if (eventClass.contains('JqMA-btn-del')) {
let [offsetX, offsetY, thisHeight] = getTouchSite(event.target, event);
if (offsetX > thisHeight || offsetY > thisHeight || offsetY < -thisHeight) {
let loadNow = document.querySelector("#pagetual-sideController #loadNow");
if (loadNow) {
simulateClick(loadNow);
} else {
alert("请启用 东方永夜机 立即翻页");
}
} else {
btnDelClick();
}
} else if (eventClass.contains('JqMA-btn-pic')) {
let [offsetX, offsetY, thisHeight] = getTouchSite(event.target, event);
if (offsetY > thisHeight * 3 || offsetY < thisHeight * -3 || offsetX > thisHeight * 3) {
btnPicwhClick();
} else if (offsetY > thisHeight) {
if (minPicwh < picwh && picwh < minPicwh + 100) {
picwh = minPicwh;
} else if (picwh <= minPicwh) {
picwh = 0
} else {
picwh -= 100;
}
picImgFilter();
} else if (offsetY < -thisHeight || offsetX > thisHeight) {
if (picwh == 0) {
picwh = minPicwh;
} else {
picwh += 100;
}
picImgFilter();
} else {
btnPicClick();
}
} else if (eventClass.contains('JqMA-btn-outerSz')) {
let [offsetX, offsetY, thisHeight] = getTouchSite(event.target, event);
if (offsetY > thisHeight * 3 || offsetY < thisHeight * -3 || offsetX > thisHeight * 3) {
scrollPicLoad();
} else if (offsetY > thisHeight) {
if (minOuterSz < outerSz && outerSz < minOuterSz + 10) {
outerSz = minOuterSz;
} else if (outerSz <= minOuterSz) {
outerSz = 0;
} else {
outerSz -= 10;
}
} else if (offsetY < -thisHeight || offsetX > thisHeight) {
if (outerSz === 0) {
outerSz = minOuterSz;
} else {
outerSz += 10;
}
} else {
btnOuterSzClick();
}
outerSz_run();
} else if (eventClass.contains('JqMA-btn-width')) {
let [offsetX, offsetY, thisHeight] = getTouchSite(event.target, event);
if (offsetY > 3 * thisHeight || offsetY < -3 * thisHeight || offsetX > 3 * thisHeight) {
readPause();
return;
} else if (offsetY > thisHeight) {
widthN -= 1;
} else if (offsetY < -thisHeight || offsetX > thisHeight) {
widthN += 1;
} else {
btnWidthClick();
return;
}
widthNFunc();
} else if (eventClass.contains('JqMA-btn-transform')) {
btnTransfClick();
} else if (eventClass.contains('JqMA-btn-scrollDiv')) {
let [offsetX, offsetY, thisHeight] = getTouchSite(event.target, event);
if (offsetY > thisHeight || offsetY < -thisHeight || offsetX > thisHeight) {
removeShadowRoot();
} else {
btnScrollDivClick();
}
} else if (eventClass.contains('JqMA-btn-down')) {
let [offsetX, offsetY, thisHeight] = getTouchSite(event.target, event);
if (offsetY > thisHeight * 3) {
const visDiv = visibleDiv([9, -9], true);
pageX.unshift(visDiv.scrollTop);
autoScrollTo(visDiv, 0);
document.querySelectorAll(".JqMA-btn-down").forEach(function(elet) {
elet.textContent = "♢";
});
} else if (offsetY < thisHeight * -3 || offsetX > thisHeight * 3) {
const visDiv = visibleDiv([9, -9], true);
pageX.unshift(visDiv.scrollTop);
autoScrollTo(visDiv, visDiv.scrollHeight);
document.querySelectorAll(".JqMA-btn-down").forEach(function(elet) {
elet.textContent = "♢";
});
} else if (offsetY > thisHeight) {
pageNextFunc("up");
} else if (offsetY < -thisHeight || offsetX > thisHeight) {
pageNextFunc("down");
} else {
btnDownClick();
}
}
});
onLongPress(document, function(event) {
const eventClass = event.target.classList;
if (eventClass.contains('JqMA-btn-Ju')) {
let inputNum = window.prompt("请输入滚动速度:(以`开头表间隔," + scrollJu + ")", smoothScroll ? "`" : "");
smoothScroll = inputNum.startsWith("`") ? 1 : 0;
if (Number(inputNum.replace("`", ""))) {
scrollJu = Number(inputNum.replace("`", ""));
scrollJu = Math.max(scrollJu, 0);
document.querySelectorAll(".JqMA-btn-Ju", "all").forEach(function(_this) {
_this.textContent = (smoothScroll ? "`" : "") + scrollJu;
});
GM_setValue("scrollJu", scrollJu);
GM_setValue("smoothScroll", smoothScroll);
}
} else if (eventClass.contains('JqMA-btn-del')) {
let newHref;
if (/[^a-z]page[=/]\d+(?=$|&)/.test(location.href)) {
let hrefSplit = location.href.split(/(?<=[^a-z]page)([=/])(?=\d)/);
openHref(getNextPage(hrefSplit));
return;
} else if (/[/_\-]\d+(\.html)?$/.test(location.href)) {
let hrefSplit = location.href.split(/([/_\-])(?=\d+(?:\.html)?$)/);
newHref = getNextPage(hrefSplit);
}
let pageEnter;
let allA = docSltAll("a");
allA.reverse();
for (let i = 0; i < allA.length; i++) {
let _this = allA[i];
if (/^\s*2\s*$/.test(_this.textContent) &&
/[^a-z]page[=/]\d+(?=$|&)/.test(_this.href)) {
pageEnter = 1;
openHref(_this.href);
break;
} else if (/^\s*(>|次のページ|下.?[章页]|下[一—].)\s*$|^\s*next\s*(page\s*)?$/i.test(_this.textContent)) {
pageEnter = 1;
simulateClick(_this);
break;
} else if (newHref && _this.href === newHref) {
pageEnter = 1;
openHref(newHref);
break;
}
}
if (!pageEnter && /[^a-z\d]\d+$/.test(location.href)) {
let hrefSplit = location.href.split(/([^a-z\d])(?=\d+$)/);
openHref(getNextPage(hrefSplit));
}
} else if (eventClass.contains('JqMA-btn-outerSz')) {
DSImg = DSImg ? 0 : 1;
event.target.style.setProperty("color", DSImg ? "green" : null, "important");
if (picZ) {
const visDiv = visibleDiv([9, -9], true);
const _scrollTop = visDiv.scrollTop;
removePicClass();
imgInterFn();
setTimeout(function() {
autoScrollTo(visDiv, _scrollTop);
}, 400);
}
if (DSImg) {
delete DSImgData[currentDomain];
} else {
DSImgData[currentDomain] = DSImg;
}
GM_setValue("DSImgData", DSImgData);
} else if (eventClass.contains('JqMA-btn-pic')) {
let inputNum = window.prompt("请输入图片链接替换(`分隔,@开头:正则且数字->[0-9]):", picReplace);
if (inputNum == "所有域名") {
let resultData = changeDataFunc(picRepData, "");
if (resultData)[picRepData, picReplace] = resultData;
} else if (typeof inputNum === "string") {
picReplace = inputNum;
if (picReplace === "") {
delete picRepData[currentDomain];
} else {
picRepData[currentDomain] = picReplace;
if (picZ) {
const visDiv = visibleDiv([9, -9], true);
const _scrollTop = visDiv.scrollTop;
removePicClass();
imgInterFn();
setTimeout(function() {
autoScrollTo(visDiv, _scrollTop);
}, 400);
}
}
}
GM_setValue("picRepData", picRepData);
} else if (eventClass.contains('JqMA-btn-width')) {
let innerWord = document.querySelector(".JqMA-inner-word");
if (innerWord) {
innerWord.remove();
docSltAll("[JqMA-mark-word]").forEach(function(element) {
element.removeAttribute("JqMA-mark-word");
});
} else {
event.target.style.setProperty("color", "green", "important");
}
if (!innerWord && textSlt.length) {
appendWord();
return;
}
waitClick(function(event) {
let _target = event.target;
while (true) {
if (_target.matches("body") || getText(_target).replace(/\s+/g, "").length > 50) {
break;
} else {
_target = _target.parentNode;
}
}
let selector = getSelector(_target);
copyToClipboard(selector);
let inputNum = window.prompt(`修改选择器:${selector}`, textSlt.length ? textSlt : selector);
if (inputNum == "所有域名") {
let resultData = changeDataFunc(textSltData, "");
if (resultData)[textSltData, textSlt] = resultData;
} else if (typeof inputNum === "string") {
textSlt = inputNum;
if (textSlt === "") {
delete textSltData[currentDomain];
} else {
textSltData[currentDomain] = textSlt;
}
} else if (inputNum === null) {
return;
}
GM_setValue("textSltData", textSltData);
appendWord();
});
} else if (eventClass.contains('JqMA-btn-down')) {
let menuNum = window.prompt(`1:跳转节点 2:保存位置 ${nextScrollTop}`, 1);
if (menuNum === "1") {
let inputNum = window.prompt("跳转第几个节点:");
if (Number(inputNum) || inputNum === "0") {
let nextNum = Number(inputNum);
pageNextFunc(nextNum);
}
} else if (menuNum === "2") {
let inputNum = window.prompt(`是否保存滚动位置?(取消关闭)${nextScrollTop}`, parseInt(visibleDiv([9, -9], true).scrollTop));
if (inputNum === null) {
nextScrollTop = 0;
} else {
nextScrollTop = Number(inputNum)
}
setValLoc("nextScrollTop", nextScrollTop);
}
} else if (eventClass.contains('JqMA-btn-scrollDiv')) {
location.reload();
} else if (eventClass.contains('JqMA-btn-transform')) {
alert(`O:
==点击:切换滚动对象
==滑动:移除#shadow-root
==长按:刷新页面
W:
==点击:输入字体大小
==滑动:上加下减
==长按:朗读或下载文字
5:
==点击:启动/停止滚动
==滑动:上加下减
==长按:输入滚动速度
♢:
==点击:回上一位置
==短滑:上/下:下/上一节点
==长滑:上/下:到底/顶部
==长按:记录本域名滚动位置
X:
==点击:隐藏/显示其他按钮
==滑动:触发 立即翻页 按钮
==长按:自动点击下一页
T:
==点击:元素取消浮动
==长按:显示操作清单
B:
==点击:切换a链接打开方式
==滑动:点击2个a链接,加载页面
==长按:横屏全屏,返回键退出
120:
==点击:开关页首图片集
==短滑:上加下减
==长滑:点击图片,修改过滤尺寸
==长按:点击图片,输入替换规则
10:
==点击:点击元素,修改过滤尺寸
==短滑:上加下减
==长滑:滚动加载图片集
==长按:开关深度搜索`);
}
});
function btnDownClick() {
if (pageX.length) {
pageX = Array.from(new Set(pageX));
if (typeof pageX[0] === "number") {
autoScrollTo(visibleDiv([9, -9], true), pageX[0]);
} else {
scrollToElement(pageX[0], {
"block": "center"
});
}
pageX.splice(0, 1);
document.querySelectorAll(".JqMA-btn-down").forEach(function(elet) {
elet.textContent = "♢";
});
}
}
function pageNextFunc(nextNum) {
pageX.unshift(visibleDiv([9, -9], true).scrollTop);
let pageDom = Array.from(document.querySelectorAll(".pagetual_pageBar,.JqMA-mark-pageNext,.JqMA-inner-all,.JqMA-inner-all > :last-child,.JqMA-inner-word > p[style*=green]"));
if (Number(nextNum) && nextNum >= pageDom.length) {
scrollToElement(pageDom.pop());
document.querySelector(".JqMA-btn-down").textContent = pageDom.length - 1;
return;
}
if (nextNum == "up") pageDom.reverse();
for (let index = 0; index < pageDom.length; index++) {
let dom = pageDom[index];
let offsetD = dom.getBoundingClientRect().top;
if (nextNum == index || (nextNum == "up" && offsetD < -0.25 * window.innerHeight) ||
(nextNum == "down" && offsetD > 0.25 * window.innerHeight)) {
scrollToElement(dom);
document.querySelector(".JqMA-btn-down").textContent = nextNum == "up" ? pageDom.length - index - 1 : index;
break;
}
}
}
let clearStyle = document.createElement('style');
function applyClearStyle() {
clearStyle.textContent = `html {
overflow-y: visible!important;
} body {
transform: translate(0%, 0%) !important;
padding: ${Dtransform}vh 0!important;
height: auto !important;
max-height: none !important;
} [JqMA-css-fixed_hide] {
opacity: 0.2!important;
}`;
document.head.appendChild(clearStyle);
setTimeout(function() {
let elements = document.querySelectorAll(':not(.JqMA-btn-all)');
for (let i = 0; i < elements.length; i++) {
const _this = elements[i];
const style = window.getComputedStyle(_this);
if (/sticky|fixed/.test(style.position) && _this.offsetHeight < 0.5 * window.innerHeight) {
_this.setAttribute("JqMA-css-fixed_hide", "1");
}
}
}, 400);
}
function btnTransfClick() {
const _prompt = prompt("请输入上下边距:(取消=关闭)", Dtransform ? Dtransform : "1");
if (_prompt === null) {
Dtransform = 0;
} else {
Dtransform = _prompt > 0 ? _prompt : 1;
}
document.querySelector(".JqMA-btn-transform").style.setProperty("color", Dtransform ? "green" : null, "important");
if (Dtransform) {
applyClearStyle();
DtransformData[currentDomain] = Dtransform;
} else {
document.head.removeChild(clearStyle);
delete DtransformData[currentDomain];
}
GM_setValue("DtransformData", DtransformData);
}
let [picRepData, picReplace] = getDataValue("picRepData", "");
function visibleDiv(_zf = [9, -9], _max = false) {
const threshold = 0.6 * window.innerHeight;
let elements = document.querySelectorAll("*");
let maxOne = null;
let maxH = 0;
for (let i = 0; i < elements.length; i++) {
let element = elements[i];
if (element.offsetHeight > threshold) {
const oldScrollTop = element.scrollTop;
for (let j = 0; j < _zf.length; j++) {
element.scrollTop += _zf[j];
if (element.scrollTop !== oldScrollTop) {
element.scrollTop -= _zf[j];
if (_max && maxOne != element) {
const eleSH = element.scrollHeight;
if (eleSH > maxH) {
maxH = eleSH;
maxOne = element;
}
} else {
return element;
}
}
}
}
}
return maxOne ? maxOne : document.body;
}
function xScrollDiv(_zf = [9, -9]) {
let elements = document.querySelectorAll("*");
let scrollEles = [];
for (let i = 0; i < elements.length; i++) {
let element = elements[i];
if (element.offsetWidth > 0.6 * window.innerWidth &&
window.getComputedStyle(element).overflowX !== "hidden") {
const oldScrollLeft = element.scrollLeft;
for (let j = 0; j < _zf.length; j++) {
element.scrollLeft += _zf[j];
if (element.scrollLeft !== oldScrollLeft) {
element.scrollLeft -= _zf[j];
scrollEles.push(element);
}
}
}
}
return scrollEles;
}
function autoScrollBy(visDiv, sJu, time = 0) {
if (visDiv) {
if (time) {
let totalMoved = 0;
const duration = 10;
const distance = sJu / time * duration;
const startTime = Date.now();
let _interval = setInterval(function() {
visDiv.scrollTop += distance;
totalMoved += distance;
const elapsedTime = Date.now() - startTime;
if (elapsedTime > time || totalMoved > sJu) {
clearInterval(_interval);
visDiv.scrollTop += sJu - totalMoved;
}
}, duration);
} else {
visDiv.scrollTop += sJu;
}
}
}
function autoScrollTo(element, scrollTo_Ju, speed = 0) {
if (element) {
if (speed === 0) {
element.scrollTop = scrollTo_Ju;
} else {
let moveJu = scrollTo_Ju - element.scrollTop;
autoScrollBy(element, moveJu, speed);
}
}
}
function downloadTxt(filename, textContent) {
let objectURL = URL.createObjectURL(new Blob([textContent], {
type: "text/plain;charset=utf-8"
}));
let a = createElement('a', {
href: objectURL,
download: filename,
style: "display:none!important;"
});
document.body.appendChild(a);
simulateClick(a);
document.body.removeChild(a);
setTimeout(function() {
URL.revokeObjectURL(objectURL);
}, 2000);
}
function changeStyle(_id, _style) {
docSltAll("head").forEach(function(elet) {
let styleElement = elet.querySelector("style#" + _id);
if (!styleElement) {
elet.appendChild(createElement('style', {
id: _id
}, _style));
} else {
if (styleElement.textContent != _style) {
styleElement.textContent = _style;
}
}
});
}
let defWidthN = GM_getValue("defWidthN", 30);
function fontInterFn() {
changeStyle("JqMA-css-textBig",
`html > body *,html > body [class] * {
font-size: ${widthN}px !important;
letter-spacing: normal !important;
line-height: normal !important;
}`);
}
function removeTextClass() {
docSltAll("style#JqMA-css-textBig").forEach(function(elet) {
elet.textContent = "";
});
}
function btnWidthClick() {
let inputNum = window.prompt(`请输入字体大小:(@=修改默认,${defWidthN})`, widthN ? widthN : defWidthN);
if (inputNum === "@") {
inputNum = window.prompt("请修改默认字体大小:", defWidthN);
defWidthN = Number(inputNum) ? Number(inputNum) : 30;
GM_setValue("defWidthN", defWidthN);
return;
}
widthN = Number(inputNum) ? Number(inputNum) : 0;
widthNFunc();
}
function widthNFunc() {
if (widthN > 0) {
widthNdata[currentDomain] = widthN;
fontInterFn();
} else {
delete widthNdata[currentDomain];
widthN = 0;
removeTextClass();
}
document.querySelector(".JqMA-btn-width").textContent = widthN ? widthN : "W";
GM_setValue("widthNdata", widthNdata);
}
let speakRate = GM_getValue("speakRate", 1);
function readStr() {
window.speechSynthesis.cancel();
let wordP = document.querySelectorAll(".JqMA-inner-word > p");
for (let i = currentStr; i < wordP.length; i++) {
let utterThis = new SpeechSynthesisUtterance();
utterThis.text = getText(wordP[i]);
utterThis.rate = speakRate;
utterThis.volume = 1.0;
window.speechSynthesis.speak(utterThis);
utterThis.onstart = function() {
currentStr = i;
wordP.forEach(function(element) {
element.removeAttribute('style');
});
wordP[currentStr].style.cssText = "color:green!important;";
innerWordAdd();
let pLen = document.querySelectorAll(".JqMA-inner-word > p").length;
if (currentStr > pLen - 9) {
const visDiv = visibleDiv([9, -9], true);
pageX.unshift(visDiv.scrollTop);
autoScrollBy(visDiv, visDiv.scrollHeight, 400);
setTimeout(function() {
btnDownClick();
}, 500);
}
if (wordP.length < pLen) {
readStr();
}
}
}
}
function getText(element) {
return element.textContent || element.innerText;
}
function readPause() {
try {
new SpeechSynthesisUtterance();
} catch (error) {
alert("浏览器不支持JS朗读!");
return;
}
let readbtn = document.querySelectorAll(".JqMA-inner-word > a")[1];
if (getText(readbtn) == "暂停") {
readbtn.textContent = "朗读";
window.speechSynthesis.cancel();
} else {
readbtn.textContent = "暂停";
readStr();
}
}
function innerWordAdd() {
let allStr = "";
docSltAll(textSlt).forEach(function(element) {
if (!element.hasAttribute('JqMA-mark-word')) {
allStr += getText(element) + " ";
element.setAttribute('JqMA-mark-word', true);
}
});
allStr = allStr.replace(/\s+/g, " ").replace(/<img[^一-鿯>]*?>/g, "");
let allStrlist = allStr.replace(/<\/?br>/g, "\n").split(/(.{1,150}(?:$|[^一-鿯0-9A-Za-z\/,,、]))/);
allStrlist = allStrlist.filter((s) => {
return s && s.trim();
});
for (let i = 0; i < allStrlist.length; i++) {
let endElement = document.querySelector(".JqMA-mark-wordEnd");
endElement.parentNode.insertBefore(createElement('p', false, allStrlist[i]), endElement);
}
}
var [textSltData, textSlt] = getDataValue("textSltData", "");
let currentStr = 0;
const htmlStyle1 = createElement('style', false, "html {overflow-y: visible!important;}");
const htmlStyle2 = createElement('style', false, "html {overflow-y: visible!important;}");
function appendWord() {
let pOuter = createElement('p', {
class: "JqMA-inner-word JqMA-inner-all"
});
const pInner = createElement('p', {
class: "JqMA-mark-wordEnd"
}, "!阅读结束!");
pOuter.appendChild(htmlStyle1);
pOuter.appendChild(pInner);
document.documentElement.prepend(pOuter);
innerWordAdd();
document.querySelector(".JqMA-inner-word").addEventListener("click", function(event) {
if (event.target.tagName === "P" && getText(readbtn) != "朗读") {
currentStr = 0;
let prevElement = event.target.previousElementSibling;
while (prevElement) {
if (prevElement.tagName === "P") {
currentStr++;
}
prevElement = prevElement.previousElementSibling;
}
readStr();
}
});
let readbtn = createElement('a', false, '朗读');
let downbtn = createElement('a', false, '下载');
let ratebtn = createElement('a', false, `语速:${speakRate}`);
document.querySelectorAll(".JqMA-inner-word").forEach(function(element) {
element.insertBefore(downbtn, element.firstChild);
element.insertBefore(readbtn, element.firstChild);
element.insertBefore(ratebtn, element.firstChild);
});
readbtn.addEventListener("click", readPause);
ratebtn.addEventListener("click", function() {
let inputNum = window.prompt("输入语速:", speakRate);
if (inputNum === null) return;
speakRate = inputNum;
this.textContent = "语速:" + speakRate;
GM_setValue("speakRate", speakRate);
if (getText(readbtn) == "朗读") return
readStr();
});
downbtn.addEventListener("click", function() {
let textContent = "";
document.querySelectorAll(".JqMA-inner-word > p").forEach(function(pDom) {
textContent += pDom.textContent;
});
downloadTxt(document.title.replace(/[\/:*?""<>|]+/g, " ").replace(/^\s+|\s+$/g, "") + ".txt", textContent);
});
autoScrollTo(visibleDiv([9, -9], true), 0);
}
let whProp = GM_getValue("whProp", 3.9);
function picSizeOut(_this) {
const natureW = _this.naturalWidth;
const natureH = _this.naturalHeight;
const imgOuterWH = _this.getAttribute("img-outerWH") || 100;
return Math.min(natureW, natureH) >= picwh &&
natureW / natureH <= whProp && imgOuterWH >= outerSz;
}
function formatStr(_url) {
if (typeof _url === "string") {
return _url.trim().replace(/&/g, "&").replace(/\\u002F/g, "/").replace(/\\[/]/g, "/");
} else {
return "";
}
}
function decodeStr(_url) {
if (_url.startsWith('http%') || _url.startsWith('https%')) {
try {
return decodeURIComponent(_url);
} catch (error) {
return _url;
}
}
return _url;
}
function delHttp(_url) {
let httpParams = [];
try {
new URL(_url).searchParams.forEach((value) => {
if (value.startsWith('http')) {
httpParams.push(decodeStr(value));
}
});
} catch (error) {
return httpParams;
}
return httpParams;
}
let preMatches = new Set();
const locOrigin = window.location.origin
const videoRegex = /https?[:%][^""<>\s]*?\.(avi|mp4|mov|m4v|m3u8|wmv|flv|f4v|webm)([?!/&%][^""<>\s]*?)?(?=[""<>\s一-鿯]|https?[:%]|$)/gi;
function xiuTan() {
if (!document.querySelector(".JqMA-btn-hrefAll")) {
const spanStyle = ".JqMA-btn-hrefSpan {margin-left: auto!important; height: 3px!important; line-height: 3px!important; color: red!important; text-align: center!important; position: static!important;}";
const hrefAllStyle = ".JqMA-btn-hrefAll {background: none!important; overflow: scroll!important; height: auto!important; max-height: calc(4vh + 4vw)!important; width: calc(15vw + 15vh)!important; bottom: 4px!important; right: 0!important;}"
const hrefStyle = ".JqMA-btn-href {text-align: left!important; position: static!important; width: 100%!important;}"
document.head.appendChild(createElement('style', false, spanStyle + hrefAllStyle + hrefStyle));
let pAll = createElement('p', {
class: 'JqMA-btn-all JqMA-btn-hrefAll'
});
pAll.appendChild(createElement('span', {
class: 'JqMA-btn-all JqMA-btn-hrefSpan'
}, "—"));
pAll.appendChild(createElement('span', {
class: 'JqMA-btn-all JqMA-btn-hrefSpan'
}, "—"));
document.documentElement.appendChild(pAll);
}
let videoList = [];
docSltAll("video").forEach(function(element) {
const src = element.currentSrc || element.src;
src && videoList.push(src);
});
let pageSource = "";
docSltAll("html").forEach(function(_this) {
pageSource += _this.outerHTML;
});
const matches = pageSource.replace(/"|['']/g, '"').match(videoRegex);
if (matches) videoList.push(...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));
let newI,
newMatches = [];
for (let i = 0; i < videoList.length; i++) {
newI = formatStr(videoList[i]);
if (!newI.replace(/[\s/]/g, "").length || /^(?!https?:)[a-z]{3,15}:/.test(newI)) continue;
newMatches.push(newI);
let delHtList = delHttp(newI);
if (delHtList.length) newMatches.push(...delHtList);
}
let firstSpan = document.querySelector(".JqMA-btn-hrefAll > span");
for (let i = 0; i < newMatches.length; i++) {
newI = addLocation(decodeStr(newMatches[i]));
if (preMatches.has(newI)) continue;
preMatches.add(newI);
firstSpan.parentNode.insertBefore(createElement('a', {
href: newI,
class: "JqMA-btn-all JqMA-btn-href"
}, newI.replace(/\/(?=$|\?)/g, "").replace(/^[^?]*[/]/, "").replace(/(?<=[^?/.]{9})[^?/.]+/, "")), firstSpan.nextSibling);
}
}
function getMinPicwh(_this) {
return Math.min(_this.naturalWidth, _this.naturalHeight);
}
function getPercentW(_this) {
return parseInt(_this.offsetWidth / window.innerWidth * 100);
}
function waitClick(afterFunc) {
document.head.appendChild(hideAllBtn);
setTimeout(function() {
docSltAll("body:not(body *)").forEach(function(_this) {
_this.addEventListener('click', tempClickFunc);
});
function tempClickFunc(event) {
event.preventDefault();
docSltAll("body").forEach(function(_this) {
_this.removeEventListener('click', tempClickFunc);
});
document.head.removeChild(hideAllBtn);
afterFunc(event);
}
}, 100);
}
function btnOuterSzClick() {
let inputNum = window.prompt(`请输入过滤尺寸:${outerSz}`);
if (Number(inputNum) || inputNum === "0") {
outerSz = Number(inputNum);
if (outerSz < minOuterSz) outerSz = minOuterSz;
outerSz_run();
}
}
function outerSz_run() {
if (outerSz < 0) outerSz = 0;
if (picZ) {
picImgFilter();
}
document.querySelectorAll(".JqMA-btn-outerSz").forEach(function(_this) {
_this.textContent = outerSz;
});
setValLoc("outerSz", outerSz);
}
function btnPicwhClick() {
let inputNum = window.prompt(`请输入 过滤尺寸:(@ = 修改默认,${picwh})`);
if (/^\d+$/.test(inputNum)) {
picwh = Number(inputNum);
if (picwh < minPicwh) picwh = minPicwh;
picImgFilter();
} else if (inputNum === "@") {
inputNum = window.prompt(`请输入 过滤宽高比,最小过滤尺寸,最小过滤宽度,最大转高清尺寸:(推荐:3.9,100,10,500)`, [whProp, minPicwh, minOuterSz, minPicHD]);
if (/^[\d.,]+$/.test(inputNum)) {
whProp = Number(inputNum.split(",")[0]);
minPicwh = Number(inputNum.split(",")[1]);
minOuterSz = Number(inputNum.split(",")[2]);
minPicHD = Number(inputNum.split(",")[3]);
picImgFilter();
GM_setValue("whProp", whProp);
GM_setValue("minPicwh", minPicwh);
GM_setValue("minOuterSz", minOuterSz);
GM_setValue("minPicHD", minPicHD);
}
}
}
function picImgFilter() {
if (picwh < 0) picwh = 0;
if (picZ) {
document.querySelectorAll(".JqMA-inner-pic > .JqMA-mark-imgLoaded").forEach(function(_this) {
if (picSizeOut(_this)) {
_this.classList.remove("JqMA-css-smallPic");
} else {
_this.classList.add("JqMA-css-smallPic");
}
});
}
document.querySelector(".JqMA-btn-pic").textContent = picwh;
setValLoc("picwh", picwh);
}
function btnPicClick() {
picZ = picZ ? 0 : 1;
document.querySelector(".JqMA-btn-pic").style.setProperty("color", picZ ? "green" : null, "important");
if (picZ) {
picZData[currentDomain] = picZ;
imgInterFn();
if (preImgArr[1].size < 9) {
scrollPicLoad();
}
} else {
removePicClass();
delete picZData[currentDomain];
}
GM_setValue("picZData", picZData);
}
let xScrDirect = 1;
function scrollPicLoad() {
const _picZ = picZ;
picZ = 0;
document.querySelectorAll(".JqMA-inner-pic").forEach(el => el.remove());
const visDiv = visibleDiv([9, -9], true);
const _scrollTop = visDiv.scrollTop;
autoScrollTo(visDiv, 0);
autoScrollBy(visDiv, visDiv.scrollHeight, 900);
setTimeout(function() {
xScrollDiv(xScrDirect > 0 ? [9] : [-9]).forEach(function(elet) {
elet.scrollLeft += 10 * window.innerWidth * xScrDirect;
});
xScrDirect = xScrDirect * -1;
autoScrollTo(visDiv, 0, 200);
setTimeout(function() {
if (_picZ) {
picZ = 1;
removePicClass();
imgInterFn();
}
setTimeout(function() {
autoScrollTo(visDiv, _scrollTop);
}, 400);
}, 400);
}, 1000);
}
function removePicClass() {
document.querySelectorAll(".pagetual_pageBar").forEach(function(_this) {
_this.classList.remove("JqMA-mark-pageNext");
});
preImgArr = [new Set(), new Set(), new Set()];
const innerPic_1 = document.querySelector(".JqMA-inner-pic");
innerPic_1 && innerPic_1.remove();
}
function addLocation(_href) {
try {
return new URL(_href, locOrigin).href;
} catch (error) {
return _href;
}
}
function getImgList(dataObj, _this, preImgNum) {
let imgList = [];
dataObj.forEach(function(i) {
i = formatStr(i);
if (!i.replace(/[\s/]/g, "").length) return;
i = addLocation(decodeStr(i));
if (!preImgArr[preImgNum].has(i)) {
preImgArr[preImgNum].add(i);
if (preImgNum != 2) preImgArr[2].add(i);
let _newA;
let newImg = createElement('img', {
src: i,
loading: 'lazy',
width: '300',
height: '100'
});
newImg.addEventListener('load', function() {
imgLoadError(newImg, _newA);
newImg.classList.add("JqMA-mark-imgLoaded");
});
newImg.addEventListener('error', function() {
imgLoadError(newImg, _newA);
});
imgList.push(newImg);
if (_this) {
newImg.setAttribute('img-outerWH', getPercentW(_this));
_this.addEventListener('load', function() {
const _percW = getPercentW(_this);
newImg.setAttribute('img-outerWH', _percW);
_newA.textContent = `${getMinPicwh(newImg)} ${_percW}`;
if (picSizeOut(newImg)) {
newImg.classList.remove("JqMA-css-smallPic");
} else {
newImg.classList.add("JqMA-css-smallPic");
}
});
_newA = document.createElement('a');
_newA.addEventListener("click", function() {
scrollOrClick(newImg, _this);
});
newImg.addEventListener("click", function() {
if (!Dhide) {
scrollOrClick(newImg, _this);
}
});
imgList.push(_newA);
}
}
});
return imgList;
}
function scrollOrClick(newImg, _this) {
const initialPosition = _this.getBoundingClientRect().top;
scrollToElement(_this, {
"block": "center"
});
if (_this.getBoundingClientRect().top == initialPosition) {
simulateClick(_this);
}
pageX.unshift(newImg);
}
let [moodNumData, moodNum] = getDataValue("moodNumData", false);
const moodStyle = createElement("style", false, "html .JqMA-inner-pic > img {width:100%!important;}")
let preImgArr = [new Set(), new Set(), new Set()];
const imgRegex_1 = /https?[:%][^""<>\s]*?\.(xbm|tif|pjp|jpg|jpeg|tiff|gif|jfif|webp|png|bmp|pjpeg|avif)([?!/&%][^""<>\s]*?)?(?=[""<>\s一-鿯]|https?[:%]|$)/gi
const imgRegex_2 = /((?<=[""])[a-z]*[/]|https?[:%])[^""<>\s]*?\.(xbm|tif|pjp|jpg|jpeg|tiff|gif|jfif|webp|png|bmp|pjpeg|avif)([?!/&%][^""<>\s]*?)?(?=[""<>\s]|https?[:%]|$)/i
let pageNext_0, pageNext_1, pageNext_2;
function imgInterFn() {
if (!document.querySelector(".JqMA-inner-pic")) {
let newP = createElement('p', {
class: "JqMA-inner-pic JqMA-inner-all"
});
newP.appendChild(htmlStyle2);
let moodchange = createElement('p', {
style: "background:green!important;",
class: `JqMA-mark-pageNext JqMA-mark-pageNum`
}, "模式切换:" + (moodNum ? "100%" : "auto"));
if (moodNum) {
newP.appendChild(moodStyle);
}
moodchange.addEventListener("click", function() {
moodNum = moodNum == false;
if (moodNum) {
newP.appendChild(moodStyle);
moodchange.textContent = "模式切换:100%";
moodNumData[currentDomain] = moodNum;
} else {
newP.removeChild(moodStyle);
moodchange.textContent = "模式切换:auto";
delete moodNumData[currentDomain];
}
GM_setValue("moodNumData", moodNumData);
});
newP.appendChild(moodchange);
const textContents = ["可见元素", "深度搜索", "文字链接"];
textContents.forEach((textContent, index) => {
newP.appendChild(createElement('p', {
style: "background:green!important;",
class: `JqMA-mark-pageNext JqMA-mark-pageNext_${index} JqMA-mark-pageNum`
}, textContent));
});
document.documentElement.prepend(newP);
}
pageNext_0 = document.querySelector(".JqMA-mark-pageNext_0");
pageNext_1 = document.querySelector(".JqMA-mark-pageNext_1");
pageNext_2 = document.querySelector(".JqMA-mark-pageNext_2");
let imgArr_0 = [];
let imgArr_1 = [];
docSltAll("*").forEach(function(_this) {
if (_this.classList.contains("pagetual_pageBar")) {
if (!_this.classList.contains("JqMA-mark-pageNext")) {
_this.classList.add("JqMA-mark-pageNext");
imgArr_0.push(createElement('p', {
class: "JqMA-mark-pageNext"
}));
if (DSImg) {
imgArr_1.push(createElement('p', {
class: "JqMA-mark-pageNext"
}));
}
}
return true;
}
let srcArr = [];
if (_this.matches("img:not(.JqMA-inner-pic > *)")) {
srcArr.push(_this.currentSrc);
} else if (_this.matches("video")) {
srcArr.push(_this.poster);
}
const backImg = window.getComputedStyle(_this).backgroundImage.split('"');
if (backImg.length > 1) {
srcArr.push(backImg[1]);
}
if (srcArr.length) {
let imgList = getImgList(srcArr, _this, 0);
if (imgList.length) imgArr_0.push(...imgList);
if (DSImg) {
let _imgHtml = "";
let closA = _this.closest('a');
if (closA) {
let clonedA = closA.cloneNode();
clonedA.removeAttribute('style');
_imgHtml = clonedA.outerHTML;
}
let clonedThis = _this.cloneNode();
clonedThis.removeAttribute('style');
clonedThis.removeAttribute('src');
clonedThis.removeAttribute('poster');
_imgHtml += clonedThis.outerHTML;
let _isp = _imgHtml.replace(/"|['']/g, '"').match(imgRegex_2);
if (_isp) {
imgList = getImgList([_isp[0]], _this, 1);
if (imgList.length) imgArr_1.push(...imgList);
}
}
}
});
imgArr_0.forEach(function(imgElement) {
pageNext_1.parentNode.insertBefore(imgElement, pageNext_1);
});
imgArr_1.forEach(function(imgElement) {
pageNext_2.parentNode.insertBefore(imgElement, pageNext_2);
});
if (DSImg) {
let _text = "";
docSltAll("body > *").forEach(function(_this) {
let clonedElement = _this.cloneNode(true);
clonedElement.querySelectorAll('style, script, noscript').forEach(el => el.remove());
_text += clonedElement.textContent;
});
_text = _text.replace(/"|['']/g, '"').match(imgRegex_1);
if (_text) {
_text = getImgList(_text, false, 2);
let innerPic = document.querySelector(".JqMA-inner-pic");
_text.forEach(function(text) {
innerPic.appendChild(text);
});
}
}
picImgCount(pageNext_0, pageNext_1, pageNext_2);
}
function imgLoadError(elet, _newA) {
picImgCount(pageNext_0, pageNext_1, pageNext_2);
let oldNatureH = elet.naturalHeight;
let oldNatureW = elet.naturalWidth;
let minWH = Math.min(oldNatureW, oldNatureH);
if (minWH < minPicHD) {
let thisSrcList = picHD(elet.currentSrc),
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) {
elet.setAttribute("src", resH.src);
return;
}
}
});
}
setTimeout(function() {
if (picSizeOut(elet)) {
elet.classList.remove("JqMA-css-smallPic");
} else {
elet.classList.add("JqMA-css-smallPic");
}
if (_newA) _newA.textContent = `${minWH} ${elet.getAttribute("img-outerWH")}`;
}, 100);
}
function prevAll(pageNext_1, _seletor) {
let siblings = Array.from(pageNext_1.parentNode.children);
let imgElements = siblings.slice(0, siblings.indexOf(pageNext_1)).filter(function(sibling) {
return sibling.matches(_seletor);
});
return imgElements;
}
let picImgTime;
function picImgCount(pageNext_0, pageNext_1, pageNext_2) {
clearTimeout(picImgTime);
picImgTime = setTimeout(function() {
let picImgLen = document.querySelectorAll(".JqMA-inner-pic > img:not(.JqMA-css-smallPic)").length;
let keJian_Img = prevAll(pageNext_1, "img:not(.JqMA-css-smallPic)").length;
let search_len = prevAll(pageNext_2, "img:not(.JqMA-css-smallPic)").length;
pageNext_0.textContent = `可见:${keJian_Img} `;
pageNext_0.appendChild(createElement("a", {
id: "JqMA-mark-pageNext_1"
}, `深度:${search_len - keJian_Img} `));
pageNext_0.appendChild(createElement("a", {
id: "JqMA-mark-pageNext_2"
}, `文字:${picImgLen - search_len}`));
}, 400);
}
function picHD(oldSrc) {
let 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.push(...delHtList);
if (!/.https?[:%]/.test(oldSrc)) {
thisSrcList.push(oldSrc.replace(/^([^?]+?)&.*$/, "$1"));
}
let newSrcList = [];
for (let i = 0; i < thisSrcList.length; i++) {
thisSrc = thisSrcList[i];
if (thisSrc != oldSrc) {
newSrcList.push(thisSrc);
}
}
return newSrcList;
}
function delHide() {
if (Dhide) {
picAimgStyle.textContent = `html .JqMA-inner-pic > a {
height: 0!important; border: 0!important;}`;
} else {
picAimgStyle.textContent = `html .JqMA-btn-all {
display:block!important;
}html .JqMA-btn-del {
opacity:1!important;}`;
}
document.head.appendChild(picAimgStyle);
}
function btnDelClick() {
Dhide = Dhide ? 0 : 1;
delHide();
setValLoc("Dhide", Dhide);
}
let nextScrollTop = getValLoc("nextScrollTop", 0);
function getNextPage(hrefSplit) {
let pNumber = Number(hrefSplit[2].split(/[^\d]/)[0]) + 1;
let newHref = hrefSplit[0] + hrefSplit[1] + pNumber + hrefSplit[2].replace(/^\d+/, "");
return newHref;
}
function openHref(newHref) {
if (openBlk) {
window.open(newHref);
} else {
location.href = newHref;
}
}
function aOpenBlank() {
docSltAll("a:not([JqMA-mark-blank])").forEach(function(_this) {
_this.setAttribute("JqMA-mark-blank", true);
if (!/^(?!https?:)[a-z]{4,15}:|^#/.test(_this.href)) {
_this.setAttribute('target', '_blank');
}
});
}
function btnBlankClick() {
openBlk = openBlk ? 0 : 1;
document.querySelector(".JqMA-btn-blank").style.setProperty("color", openBlk ? "green" : null, "important");
if (openBlk) {
aOpenBlank();
openBlkData[currentDomain] = openBlk;
} else {
delete openBlkData[currentDomain];
docSltAll("[JqMA-mark-blank]").forEach(function(_this) {
_this.removeAttribute('JqMA-mark-blank');
_this.removeAttribute('target');
});
}
setValLoc("openBlkData", openBlkData);
}
let fullBodyStyle = document.createElement("style");
function fullScreen() {
if (document.fullscreenElement) {
return;
}
document.documentElement.requestFullscreen();
fullBodyStyle.textContent = `.JqMA-inner-all,body {width: ${Drotate_W}vw!important; max-width: none!important; min-width: none!important;}`;
document.head.appendChild(fullBodyStyle);
screen.orientation.lock = hengPin;
screen.orientation.lock('landscape');
}
let Drotate = getValLoc("Drotate", 0);
let Drotate_W = getValLoc("Drotate_W", 100);
function scrollRun() {
Dscroll = Dscroll ? 0 : 1;
clearInterval(timeDown);
document.querySelector(".JqMA-btn-Ju").style.setProperty("color", Dscroll ? "green" : null, "important");
if (Dscroll) {
timeDown = setInterval(function() {
autoScrollBy(visibleDiv(direction > 0 ? [9] : [-9]), direction * scrollJu * window.innerHeight * 0.05, smoothScroll ? 0 : 800);
}, 810);
GM_setValue("scrollJu", scrollJu);
}
}
function btnJuClick() {
scrollRun();
setValLoc("Dscroll", Dscroll);
}
})();
}