// ==UserScript==
// @name 手机看图、小说适配
// @namespace http://tampermonkey.net/
// @version 9.389
// @description 页面旋转,自动滚动,图片集合
// @author You
// @match *://*/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=pixabay.com
// @grant none
// @require https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js
// @license MIT
// ==/UserScript==
(function() {
'use strict';
if ($('.JqScroll').length > 0) {
return
}
var winW;
if ($(window).width() > $(window).height()) {
winW = $(window).height() * 0.9;
} else {
winW = $(window).width();
}
var width = winW * 0.125;
var height = winW * 0.1;
var top = $(window).height() * 0.35 - winW * 0.05;
var fontSz = winW * 0.036;
var jianG = winW * 0.1;
var left2 = -0.125 * winW * 0.125;
var left = winW * 0.125 + left2;
var twoCss = "position:absolute; top:0; left: 0; overflow: visible; width: 100%!important; height: auto!important; z-index: 2147483646!important; padding: 0 0 1500px 0!important; margin: 0; border: 0; background-color: black;"
var aScss = "border-radius: " + (width * 0.1) + "px;cursor: pointer; opacity: 0.8; z-index: 2147483647!important; padding: 0!important; font-weight: bold; font-size: " + fontSz + "px !important;line-height:12px!important; border:2px solid white;height:" + height + "px;background-color:black;color:white;position:fixed;width:" + width + "px;left:0%; top: 15%; ";
var sameCss = aScss + "margin-left:" + left + "px;";
var sameCss2 = aScss + "margin-left:" + left2 + "px;";
var scrollJu = 270;
var secZ = 2;
$("body").append("<input type='button' class='JqScroll' id='Jscroll-jian' value='-' style='" + sameCss + "px;margin-top:" + (top - jianG) + "px'>")
.append("<input type='button' class='JqScroll' id='Jscroll-rotate' value='R' style='" + sameCss + "px;margin-top:" + (top) + "px'>")
.append("<input type='button' class='JqScroll' id='Jscroll-jia' value='+' style='" + sameCss + "px;margin-top:" + (top - 2 * jianG) + "px'>")
.append("<input type='button' class='JqScroll' id='Jscroll-Ju' value='" + scrollJu + "' style='" + sameCss + "px;margin-top:" + (top - 3 * jianG) + "px'>")
.append("<input type='button' class='JqScroll' id='Jscroll-sec' value='" + secZ + "' style='" + sameCss + "px;margin-top:" + (top - 4 * jianG) + "px'>")
.append("<input type='button' class='JqScroll' id='Jscroll-width' value='W' style='" + sameCss2 + "px;margin-top:" + (top - jianG) + "px'>")
.append("<input type='button' class='JqScroll' id='Jscroll-pic' value='P' style='" + sameCss2 + "px;margin-top:" + (top - 2 * jianG) + "px'>")
.append("<input type='button' class='JqScroll' id='Jscroll-xy' value='▽' style='" + sameCss2 + "px;margin-top:" + (top - 3 * jianG) + "px'>")
.append("<input type='button' class='JqScroll' id='Jscroll-up' value='△' style='" + sameCss2 + "px;margin-top:" + (top - 4 * jianG) + "px'>")
.append("<input type='button' class='JqScroll' id='Jscroll-del' value='X' style='" + sameCss2 + "px;margin-top:" + (top) + "px'>")
$("<style>" +
"html {" +
"overflow-x: scroll;" +
"scroll-behavior: auto !important;}" +
"#Jscroll-ul *{" +
"padding: 0 !important;" +
"margin: 0 !important;" +
"position: static !important;" +
"float: none !important;" +
"border-radius: 0 !important;" +
"height: auto !important;" +
"max-height:" + (winW * 6) + "px !important;" +
"opacity: 1 !important;" +
"visibility: visible !important;" +
"background-color: black !important;" +
"object-fit: contain !important;" +
"background-image: none !important;}" +
"#Jscroll-ul *::before,#Jscroll-ul *::after{" +
"display: none !important;}" +
"#Jscroll-ul > img{" +
"border-bottom: 1px solid gray !important;}" +
"#Jscroll-ul img{" +
"display: block;" +
"min-height:" + (winW * 0.5) + "px !important;" +
"width: 100% !important;}" +
"#Jscroll-ul a{" +
"display: inline-block;" +
"min-height:" + (winW * 0.15) + "px !important;" +
"width: auto;" +
"min-width: calc(50% - 1px) !important;" +
"border-top: 1px solid red !important;" +
"border-bottom: 1px solid red !important;" +
"border-right: 1px solid red !important;" +
"font-size:" + (winW * 0.05) + "px !important;" +
"vertical-align:top;" +
"color: white !important;" +
"text-decoration: none !important;" +
"line-height: normal !important;}" +
"</style>").appendTo('head');
var Drotate = 0;
var xMove = 0;
$("body").on('touchstart', '#Jscroll-rotate', function() {
Drotate += 1;
if (Drotate % 2 != 0) {
$("#Jscroll-rotate").css("color", "green");
var wrap_rotate;
var wrap_rotate_inner;
if ($('#wrap_rotate').length == 0) {
wrap_rotate = $('<div />', {
id: "wrap_rotate"
});
wrap_rotate_inner = $('<div />', {
id: "wrap_rotate_inner"
});
$('body').wrapInner(wrap_rotate_inner).wrapInner(wrap_rotate);
}
wrap_rotate = $('#wrap_rotate');
wrap_rotate_inner = $('#wrap_rotate_inner');
var window_width = $(window).height();
window.scrollTo(0, 3 * window_width);
setTimeout(function() {
wrap_rotate.append($(".JqScroll"));
wrap_rotate.attr('style', "z-index: 2147483647!important; overflow: visible; height: " + (window_width) + "px; width: auto;");
wrap_rotate_inner.attr('style', "z-index: 2147483647!important; position: relative; left: -100%; -webkit-transform: rotateZ(-90deg); -webkit-transform-origin-x: 100%; -webkit-transform-origin-y: 0%; -moz-transform: rotateZ(-90deg); -moz-transform-origin-x: 100%; -moz-transform-origin-y: 0%;float: right; width: " + window_width + "px;");
xMove = 1;
$("body").css({
"overflow": "visible",
});
$("html").css({
"overflow-x": "visible",
});
$("#wrap_rotate").css({
"min-width": $("#wrap_rotate_inner").outerHeight() + 1500,
});
window.scrollTo(0, 0);
}, 200);
} else {
$("#Jscroll-rotate").css("color", "white");
xMove = 0;
$("html").css({
"overflow-x": "scroll",
});
setTimeout(function() {
$('#wrap_rotate').attr('style', "");
$('#wrap_rotate_inner').attr('style', "");
}, 200);
}
});
var widthN = 12;
var fontZ;
$("body").on('touchstart', '#Jscroll-width', function() {
var fSize = parseInt($(document).width() / widthN);
$("#Jscroll-width").css("color", "green");
if (widthN > 17) {
fSize = "inherit";
$("#Jscroll-width").css("color", "white");
}
function interFn() {
$(":not(:has(div,li))").filter(function() {
return $(this).is('p') || $(this).is('strong') || $(this).clone().children().remove().end().text().length > 100;
}).css({
"background-color": "black",
"color": "white",
"font-size": fSize,
"line-height": "normal",
});
}
clearInterval(fontZ);
interFn();
fontZ = setInterval(interFn, 4 * 1000);
$("#Jscroll-width").val(20 - widthN);
if (widthN == 18) {
$("#Jscroll-width").val("W");
}
if (fSize == "inherit") {
widthN = 10;
}
widthN += 2;
});
function clearBlank(urlB) {
return urlB.trim().split(" ")[0];
}
var widthZ;
var downImg;
var picZ = 0;
$("body").on('touchstart', "#Jscroll-pic", function() {
clearInterval(widthZ);
clearInterval(downImg);
$("#Jscroll-ul").remove();
picZ += 1;
var imgAr = [];
function interFn() {
var preArr = [];
var dataObj = {};
var newImgAr = [];
$("div,li,a,img,[srcset],[poster]").each(function() {
var _img = $(this);
if (!_img.parent().is("#Jscroll-ul") && !_img.parent().parent().is("#Jscroll-ul")) {
var _backImg = _img.css("background-image").split("\"");
Object.assign(dataObj, {
"_src": _img.attr("src") ? _img.attr("src") : "",
"_srcset": _img.attr("srcset") ? _img.attr("srcset") : "",
"_poster": _img.attr("poster") ? _img.attr("poster") : "",
"_backImg": _backImg.length > 1 ? _backImg[1] : "",
});
Object.assign(dataObj, _img.data());
$.each(dataObj, function(v, i) {
i = i.toString();
if (/[/?]/.test(i) && (!/[.](gif)([^a-z]|$)/i.test(i) || _img.outerHeight() > 180)) {
i = clearBlank(i);
if (picZ == 1 || picZ == 3 || picZ == 4) {
newImgAr.push("<img src='" + i + "'>");
}
if (picZ == 2 && _img.closest("a").length != 0 && preArr.indexOf(i) == -1) {
newImgAr.push(_img.closest("a").clone(true).removeClass().empty().append("<img src='" + i + "'>"));
preArr.push(i);
}
}
});
if (picZ == 3 && _img.is("a")) {
newImgAr.push(_img.clone(true).removeClass().empty()
.html(_img.attr("title") ? _img.attr("title") : _img.text()));
}
}
});
newImgAr = Array.from(new Set(newImgAr));
if (newImgAr.toString() != imgAr.toString()) {
if (picZ == 4 || picZ == 1){
var newArrEx = newImgAr.filter(function(n) {
return imgAr.indexOf(n) == -1
});
$("#Jscroll-ul").append(newArrEx);
}else{
$("#Jscroll-ul").html(newImgAr);
}
var isSupportLoading = 'loading' in document.createElement('img');
if (isSupportLoading) {
$("#Jscroll-ul img").attr("loading", "lazy");
}
$("#Jscroll-ul>a:has(img)").css({
"width": "100%",
"display": "block",
});
$("#Jscroll-ul img").on('error', function() {
$(this).hide();
if($(this).parent().is("a")){
$(this).parent().hide();
}
});
$("#Jscroll-ul img").on("load", function() {
if (this.naturalWidth < 100 || this.naturalHeight < 100) {
$(this).hide();
if($(this).parent().is("a")){
$(this).parent().hide();
}
}
});
imgAr = newImgAr;
}
}
if (picZ < 5) {
if (xMove == 1) {
$("#wrap_rotate_inner").prepend("<div id='Jscroll-ul' style='" + twoCss + "'>");
} else {
$("body").prepend("<div id='Jscroll-ul' style='" + twoCss + "'>");
$("body").css({
"height": "auto"
});
}
$("#Jscroll-pic").css("color", "green").val(picZ);
interFn()
widthZ = setInterval(interFn, 6000);
if (picZ == 4 && xMove == 0) {
downImg = setInterval(function() {
var ulTop = parseInt($("#Jscroll-ul").css("top"));
var newTop = parseInt($(document).height() - $("#Jscroll-ul").outerHeight()) - 1;
if(ulTop < newTop){
$("#Jscroll-ul").css({
"top": newTop,
});
window.scrollBy(0, newTop - ulTop);
}
}, 1000);
}
} else {
$("#Jscroll-pic").css("color", "white").val("P");
picZ = 0;
}
});
$("body").on('click', "#Jscroll-ul>*:not(a)", function(e) {
var touchX = e.clientX;
var touchY = e.clientY;
var howH = 0.7;
var scrollH = 0.6;
if (xMove == 1) {
window.scrollBy({
left: $(window).width() * howH * (touchX > $(window).width() * scrollH ? 1 : -1),
top: 0,
behavior: 'auto'
});
} else {
window.scrollBy({
left: 0,
top: $(window).height() * howH * (touchY > $(window).height() * scrollH ? 1 : -1),
behavior: 'auto'
});
}
});
var timeout_7;
$("body").on('touchstart', '#Jscroll-pic', function() {
timeout_7 = setTimeout(function() {
clearInterval(widthZ);
$("#Jscroll-ul").remove();
$("#Jscroll-pic").css("color", "white").val("P");
picZ = 0;
}, 500);
}).on('touchend touchmove', '#Jscroll-pic', function() {
clearTimeout(timeout_7);
});
$("body").on('touchstart', '#Jscroll-sec', function() {
secZ -= 1;
if (secZ < 0) {
secZ = 3
}
if (secZ < 1) {
secZ = 0.6
}
$("#Jscroll-sec").val(secZ);
});
var Dxy = 0;
var pageX;
var pageY;
var timeHu;
$("body").on('touchstart', '#Jscroll-xy', function() {
var toH;
if (xMove != 1) {
toH = $(document).height();
} else {
toH = $("#wrap_rotate_inner").outerHeight() - 250;
}
Dxy += 1;
clearTimeout(timeHu);
if (Dxy % 2 == 1) {
pageX = $(window).scrollLeft();
pageY = $(window).scrollTop();
if (xMove == 1) {
window.scrollTo(toH, 0);
} else {
window.scrollTo(0, toH);
}
$("#Jscroll-xy").val("=");
$("#Jscroll-up").val("=");
timeHu = setTimeout(function() {
Dxy += 1;
$("#Jscroll-up").val("△");
$("#Jscroll-xy").val("▽");
}, 8 * 1000);
} else {
window.scrollTo(pageX, pageY);
$("#Jscroll-up").val("△");
$("#Jscroll-xy").val("▽");
}
});
$("body").on('touchstart', '#Jscroll-up', function() {
Dxy += 1;
clearTimeout(timeHu);
if (Dxy % 2 == 1) {
pageX = $(window).scrollLeft();
pageY = $(window).scrollTop();
window.scrollTo(0, 0);
$("#Jscroll-xy").val("=");
$("#Jscroll-up").val("=");
timeHu = setTimeout(function() {
Dxy += 1;
$("#Jscroll-up").val("△");
$("#Jscroll-xy").val("▽");
}, 8 * 1000);
} else {
window.scrollTo(pageX, pageY);
$("#Jscroll-up").val("△");
$("#Jscroll-xy").val("▽");
}
});
setTimeout(function() {
$(".JqScroll").hide();
$("#Jscroll-del").show().css({
"opacity": "0.4",
"-webkit-transform": "scale(0.72)",
"-moz-transform": "scale(0.72)",
"transform": "scale(0.72)",
});
}, 100);
var Dhide = 1;
$("body").on('touchstart', '#Jscroll-del', function() {
Dhide += 1;
if (Dhide % 2 != 0) {
$(".JqScroll").hide();
$("#Jscroll-del").show().css({
"opacity": "0.4",
"-webkit-transform": "scale(0.72)",
"-moz-transform": "scale(0.72)",
"transform": "scale(0.72)",
});
} else {
$(".JqScroll").show();
$("#Jscroll-del").css({
"opacity": "0.8",
"-webkit-transform": "scale(1)",
"-moz-transform": "scale(1)",
"transform": "scale(1)",
});
if (Dscroll % 2 != 0 && secZ < 1.5) {
Dscroll += 1;
$("#Jscroll-Ju").css("color", "white");
clearInterval(timeDown);
}
}
});
var timeout_2;
$("body").on('touchstart', '#Jscroll-del', function() {
timeout_2 = setTimeout(function() {
$(".JqScroll").hide();
$("#Jscroll-del").css({
"opacity": "0.4",
"-webkit-transform": "scale(0.72)",
"-moz-transform": "scale(0.72)",
"transform": "scale(0.72)",
});
if (Dhide % 2 == 0) {
Dhide += 1;
}
}, 700);
}).on('touchend touchmove', '#Jscroll-del', function() {
clearTimeout(timeout_2);
});
var timeout_3;
$("body").on('touchstart', function() {
timeout_3 = setTimeout(function() {
$("#Jscroll-del").show();
}, 500);
}).on('touchend touchmove', function() {
clearTimeout(timeout_3);
});
$("body").on('touchstart', '#Jscroll-jia', function() {
scrollJu += 45;
$("#Jscroll-Ju").val(scrollJu);
});
$("body").on('touchstart', '#Jscroll-jian', function() {
scrollJu -= 45;
$("#Jscroll-Ju").val(scrollJu);
});
var timeout_4;
$("body").on('touchstart', '#Jscroll-jian', function() {
timeout_4 = setTimeout(function() {
scrollJu -= 45 * 15;
$("#Jscroll-Ju").val(scrollJu);
}, 500);
}).on('touchend touchmove', '#Jscroll-jian', function() {
clearTimeout(timeout_4);
});
var timeout_5;
$("body").on('touchstart', '#Jscroll-jia', function() {
timeout_5 = setTimeout(function() {
scrollJu += 45 * 15;
$("#Jscroll-Ju").val(scrollJu);
}, 500);
}).on('touchend touchmove', '#Jscroll-jia', function() {
clearTimeout(timeout_5);
});
var Dscroll = 0;
var timeDown;
var timeout_6;
$("body").on('touchstart', '#Jscroll-Ju', function() {
timeout_6 = setTimeout(function() {
scrollJu = 180;
$("#Jscroll-Ju").val(scrollJu);
Dscroll += 1;
if (Dscroll % 2 != 0) {
$("#Jscroll-Ju").css("color", "green");
clearInterval(timeDown);
timeDown = setInterval(function() {
if (xMove == 1) {
window.scrollBy(scrollJu, 1)
window.scrollBy(0, -1);
} else {
window.scrollBy(0, scrollJu)
}
}, secZ * 1000);
} else {
$("#Jscroll-Ju").css("color", "white");
clearInterval(timeDown);
}
}, 500);
}).on('touchend touchmove', '#Jscroll-Ju', function() {
clearTimeout(timeout_6);
});
$("body").on('touchstart', '#Jscroll-Ju', function() {
Dscroll += 1;
if (Dscroll % 2 != 0) {
$("#Jscroll-Ju").css("color", "green");
clearInterval(timeDown);
timeDown = setInterval(function() {
if (xMove == 1) {
window.scrollBy({
left: scrollJu,
top: 0,
behavior: 'auto'
});
} else {
window.scrollBy({
left: 0,
top: scrollJu,
behavior: 'auto'
});
}
}, secZ * 1000);
} else {
$("#Jscroll-Ju").css("color", "white");
clearInterval(timeDown);
}
});
// Your code here...
})();