// ==UserScript==
// @name 手机看图、小说适配
// @namespace http://tampermonkey.net/
// @version 9.98
// @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';
$.fn.longPress = function(fn) {
var timeout;
var $this = this;
for (var i = 0; i < $this.length; i++) {
(function(target) {
var timeout;
target.addEventListener('touchstart', function(event) {
timeout = setTimeout(function() {
//fn.apply(target);
fn(event);
}, 600);
}, false);
target.addEventListener('touchend', function(event) {
clearTimeout(timeout);
}, false);
target.addEventListener('touchmove', function(event) {
clearTimeout(timeout);
}, false);
})($this[i]);
}
};
var Dscroll = 0;
var Dxy = 0;
var timeDown;
var scrollJu = 180;
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 degZ = 0;
var secZ = 2;
var scaleZ = 1;
var xMove = 0;
var twoCss = "position:absolute; top: 0; left: 0; overflow: auto; width: 100%!important; height: auto!important; z-index: 2147483646!important; padding: 0!important; margin: 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;";
if ($('.JqScroll').length > 0) {
return
}
$("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-deg' value='" + degZ + "°' style='" + sameCss2 + "px;margin-top:" + (top - 4 * jianG) + "px'>")
.append("<input type='button' class='JqScroll' id='Jscroll-scale' value='" + scaleZ + "' style='" + sameCss2 + "px;margin-top:" + (top - 5 * jianG) + "px'>")
.append("<input type='button' class='JqScroll' id='Jscroll-del' value='X' style='" + sameCss2 + "px;margin-top:" + (top) + "px'>")
.append("<ul id='Jscroll-ul' style='" + twoCss + "'>");
var cssW = "auto";
$("body").on('touchstart', '#Jscroll-rotate', function() {
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);
} else {
$('#wrap_rotate_inner').each(function() {
// 先获取内部元素
var _dom = $(this).html();
$(this).after(_dom).remove();
});
$('#wrap_rotate').each(function() {
// 先获取内部元素
var _dom = $(this).html();
$(this).after(_dom).remove();
});
$("body").css({
"height": "auto",
"width": cssW
});
xMove = 0;
return
}
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', "overflow-y: hidden; overflow-x: auto; height: " + (window_width + 10) + "px;width:" + ($(document).height() + 10) + "px;");
wrap_rotate_inner.attr('style', "padding: 0 0 200px 0; 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;
cssW = $("body").css("width");
$("body").css({
"width": "auto"
});
var wH = 0;
$("img").each(function() {
wH += $(this).height();
});
if ($("#wrap_rotate").width() < wH + 1500) {
$("#wrap_rotate").width(wH + 1500);
}
}, 200);
});
var fSize;
var fontZ;
var widthN = 12;
$("body").on('touchstart', '#Jscroll-width', function() {
fSize = parseInt($(document).width() / widthN);
if (widthN > 17) {
fSize = "inherit"
}
$("*").filter(function(index) {
return ($(this).text().length > 100 || $(this).is('p')) && $(this).has("div,a").length == 0;
}).css({
"background-color": "black",
"color": "white",
"font-size": fSize,
"line-height": "normal"
});
clearInterval(fontZ);
fontZ = setInterval(function() {
$("*").filter(function(index) {
return ($(this).text().length > 100 || $(this).is('p')) && $(this).has("div,a").length == 0;
}).css({
"background-color": "black",
"color": "white",
"font-size": fSize,
"line-height": "normal"
});
}, 4 * 1000);
$("#Jscroll-width").val(20 - widthN);
if (widthN == 18) {
$("#Jscroll-width").val("W");
}
if (fSize == "inherit") {
widthN = 10;
}
widthN += 2;
});
var widthZ;
var picZ = 0;
var imgAr;
$("body").on('touchstart', "#Jscroll-pic", function() {
clearInterval(widthZ);
$("#Jscroll-ul").remove();
if (xMove == 1) {
$("#wrap_rotate_inner").append("<ul id='Jscroll-ul' style='" + twoCss + "'>");
} else {
$("body").append("<ul id='Jscroll-ul' style='" + twoCss + "'>");
}
picZ += 1;
if (picZ < 4) {
imgAr = []
if (picZ == 3) {
$("div,a,li,p").each(function(index) {
if ($(this).css("background-image").indexOf("url(") > -1) {
if ($(this).is("a")) {
if (!$(this).is('[href]')) {
imgAr.push($(this).clone(true).removeClass());
} else {
imgAr.push("<a href='" + $(this).attr("href") + "'><img src='" + $(this).css("background-image").replace('url("', "").replace('")', "") + "'></a>");
}
} else {
imgAr.push("<img src='" + $(this).css("background-image").replace('url("', "").replace('")', "") + "'>");
}
}
});
imgAr = Array.from(new Set(imgAr));
$("#Jscroll-ul").append(imgAr);
}
if (picZ == 1) {
$("img").each(function(index) {
imgAr.push("<img src='" + $(this).attr('src') + "'>");
});
imgAr = Array.from(new Set(imgAr));
$("#Jscroll-ul").append(imgAr);
}
if (picZ == 2) {
$("a:has(img)").each(function(index) {
if (!$(this).is('[href]')) {
imgAr.push($(this).clone(true).removeClass());
} else {
imgAr.push("<a href='" + $(this).attr("href") + "'><img src='" + $(this).find("img:first-child").attr('src') + "'></a>");
}
});
imgAr = Array.from(new Set(imgAr));
$("#Jscroll-ul").append(imgAr);
}
$("#Jscroll-ul *").css({
"font-size": "0"
});
$("#Jscroll-ul a,#Jscroll-ul img").css({
"height": "auto",
"opacity": "1",
"display": "block",
"width": $("#Jscroll-ul").width(),
"object-fit": "contain",
"padding": "0",
"margin": "0",
"max-height": 1500
});
if (xMove == 1) {
$("#wrap_rotate").width($("#Jscroll-ul").height() + 1500);
} else {
if ($("body").height() < $("#Jscroll-ul").height() + 300) {
$("body").height($("#Jscroll-ul").height() + 300);
}
}
$("#Jscroll-pic").css("color", "green").val(picZ);
widthZ = setInterval(function() {
$("#Jscroll-ul").remove();
if (xMove == 1) {
$("#wrap_rotate_inner").append("<ul id='Jscroll-ul' style='" + twoCss + "'>");
} else {
$("body").append("<ul id='Jscroll-ul' style='" + twoCss + "'>");
}
imgAr = []
if (picZ == 3) {
$("div,a,li,p").each(function(index) {
if ($(this).css("background-image").indexOf("url(") > -1) {
if ($(this).is("a")) {
if (!$(this).is('[href]')) {
imgAr.push($(this).clone(true).removeClass());
} else {
imgAr.push("<a href='" + $(this).attr("href") + "'><img src='" + $(this).css("background-image").replace('url("', "").replace('")', "") + "'></a>");
}
} else {
imgAr.push("<img src='" + $(this).css("background-image").replace('url("', "").replace('")', "") + "'>");
}
}
});
imgAr = Array.from(new Set(imgAr));
$("#Jscroll-ul").append(imgAr);
}
if (picZ == 1) {
$("img").each(function(index) {
imgAr.push("<img src='" + $(this).attr('src') + "'>");
});
imgAr = Array.from(new Set(imgAr));
$("#Jscroll-ul").append(imgAr);
}
if (picZ == 2) {
$("a:has(img)").each(function(index) {
if (!$(this).is('[href]')) {
imgAr.push($(this).clone(true).removeClass());
} else {
imgAr.push("<a href='" + $(this).attr("href") + "'><img src='" + $(this).find("img:first-child").attr('src') + "'></a>");
}
});
imgAr = Array.from(new Set(imgAr));
$("#Jscroll-ul").append(imgAr);
}
$("#Jscroll-ul *").css({
"font-size": "0"
});
$("#Jscroll-ul a,#Jscroll-ul img").css({
"height": "auto",
"opacity": "1",
"display": "block",
"width": $("#Jscroll-ul").width(),
"object-fit": "contain",
"padding": "0",
"margin": "0",
"max-height": 1500
});
if (xMove == 1) {
$("#wrap_rotate").width($("#Jscroll-ul").height() + 1500);
} else {
if ($("body").height() < $("#Jscroll-ul").height() + 300) {
$("body").height($("#Jscroll-ul").height() + 300);
}
}
}, 4000);
} else {
$("#Jscroll-pic").css("color", "white").val("P");
if (xMove == 1) {
$("#wrap_rotate").width($("#wrap_rotate_inner").height() + 10);
} else {
$("body").css({
"height": "auto"
});
}
picZ = 0;
}
});
$("body").on('touchstart', '#Jscroll-sec', function() {
secZ -= 1;
if (secZ < 0) {
secZ = 4
}
if (secZ < 1) {
secZ = 0.6
}
$("#Jscroll-sec").val(secZ);
});
$("body").on('touchstart', '#Jscroll-jia', function() {
scrollJu += 45;
$("#Jscroll-Ju").val(scrollJu);
});
var scaleTime;
$("body").on('touchstart', '#Jscroll-deg', function() {
degZ += 90;
degZ = degZ % 360;
$("#Jscroll-deg").val(degZ + "°");
$("img").css({
"-webkit-transform": "rotate(" + degZ + "deg) scale(" + scaleZ + ")",
"-moz-transform": "rotate(" + degZ + "deg) scale(" + scaleZ + ")"
});
clearInterval(scaleTime);
scaleTime = setInterval(function() {
$("img").css({
"-webkit-transform": "rotate(" + degZ + "deg) scale(" + scaleZ + ")",
"-moz-transform": "rotate(" + degZ + "deg) scale(" + scaleZ + ")"
});
}, 4000);
});
var timeout;
$("body").on('touchstart', '#Jscroll-scale', function() {
timeout = setTimeout(function() {
scaleZ = 0.56;
$("#Jscroll-scale").val(scaleZ.toFixed(2));
$("img").css({
"-webkit-transform": "rotate(" + degZ + "deg) scale(" + scaleZ + ")",
"-moz-transform": "rotate(" + degZ + "deg) scale(" + scaleZ + ")"
});
clearInterval(scaleTime);
scaleTime = setInterval(function() {
$("img").css({
"-webkit-transform": "rotate(" + degZ + "deg) scale(" + scaleZ + ")",
"-moz-transform": "rotate(" + degZ + "deg) scale(" + scaleZ + ")"
});
}, 4000);
}, 600);
}).on('touchend touchmove', '#Jscroll-scale', function() {
clearTimeout(timeout);
});
$("body").on('touchstart', '#Jscroll-scale', function() {
if (scaleZ == 0.56) {
scaleZ = 0.9
}
scaleZ += 0.1;
if (scaleZ > 1.25) {
scaleZ += 0.1
}
if (scaleZ > 1.65) {
scaleZ = 0.56
}
$("#Jscroll-scale").val(scaleZ.toFixed(2));
$("img").css({
"-webkit-transform": "rotate(" + degZ + "deg) scale(" + scaleZ + ")",
"-moz-transform": "rotate(" + degZ + "deg) scale(" + scaleZ + ")"
});
clearInterval(scaleTime);
scaleTime = setInterval(function() {
$("img").css({
"-webkit-transform": "rotate(" + degZ + "deg) scale(" + scaleZ + ")",
"-moz-transform": "rotate(" + degZ + "deg) scale(" + scaleZ + ")"
});
}, 4000);
});
var toH;
$("body").on('touchstart', '#Jscroll-xy', function() {
if (xMove != 1) {
toH = $(document).height();
} else {
toH = $("#wrap_rotate_inner").height() - 500;
}
Dxy += 1;
if (Dxy % 2 != 0) {
if (xMove == 1) {
window.scrollTo(toH, 0);
} else {
window.scrollTo(0, toH);
};
$("#Jscroll-xy").val("△");
} else {
window.scrollTo(0, 0)
$("#Jscroll-xy").val("▽");
}
});
setTimeout(function() {
$(".JqScroll").hide();
$("#Jscroll-del").show().css({
"opacity": "0.4",
"-webkit-transform": "scale(0.72)",
"-moz-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)"
});
} else {
$(".JqScroll").show();
$("#Jscroll-del").css({
"opacity": "0.8",
"-webkit-transform": "scale(1)",
"-moz-transform": "scale(1)"
});
}
});
$("#Jscroll-del").longPress(function() {
setTimeout(function() {
$(".JqScroll").hide();
$("#Jscroll-del").css({
"opacity": "0.4",
"-webkit-transform": "scale(0.72)",
"-moz-transform": "scale(0.72)"
});
if (Dhide % 2 == 0) {
Dhide += 1;
}
}, 100);
});
$("body").longPress(function() {
$("#Jscroll-del").show();
});
$("body").on('touchstart', '#Jscroll-jian', function() {
scrollJu -= 45;
$("#Jscroll-Ju").val(scrollJu);
});
$("#Jscroll-jian").longPress(function() {
scrollJu -= 135;
$("#Jscroll-Ju").val(scrollJu);
});
$("#Jscroll-jia").longPress(function() {
scrollJu += 135;
$("#Jscroll-Ju").val(scrollJu);
});
$("#Jscroll-Ju").longPress(function() {
scrollJu = 180;
$("#Jscroll-Ju").val(scrollJu);
});
$("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(scrollJu, 1)
window.scrollBy(0, -1);
} else {
window.scrollBy(0, scrollJu)
}
}, secZ * 1000);
} else {
$("#Jscroll-Ju").css("color", "white");
clearInterval(timeDown);
}
});
// Your code here...
})();