// ==UserScript== // @name 手机看图、小说适配 // @namespace http://tampermonkey.net/ // @version 9.199 // @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 // @downloadURL none // ==/UserScript== (function() { 'use strict'; 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; left: 0; overflow: visible; width: 100%!important; height: 100px!important; z-index: 2147483646!important; padding: 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;"; if ($('.JqScroll').length > 0) { return } $("body").append("") .append("") .append("") .append("") .append("") .append("") .append("") .append("") .append("") var cssW = "auto"; var Drotate = 0; $("body").on('touchstart', '#Jscroll-rotate', function() { Drotate += 1; if (Drotate % 2 != 0) { var wrap_rotate; var wrap_rotate_inner; if ($('#wrap_rotate').length == 0) { wrap_rotate = $('
', { id: "wrap_rotate" }); wrap_rotate_inner = $('
', { 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', "overflow-y: hidden; overflow-x: auto; height: " + (window_width + 10) + "px;width:" + ($(document).height() + 10) + "px;"); wrap_rotate_inner.attr('style', "padding: 0; height:auto; 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" }); if ($("#wrap_rotate").width() < ($("#wrap_rotate_inner").outerHeight() + 1500)) { $("#wrap_rotate").width($("#wrap_rotate_inner").outerHeight() + 1500); } }, 200); } else { xMove = 0; setTimeout(function() { $('#wrap_rotate').attr('style', ""); $('#wrap_rotate_inner').attr('style', ""); $("body").css({ "width": cssW }); }, 200); } }); var fSize; var fontZ; var widthN = 12; $("body").on('touchstart', '#Jscroll-width', function() { fSize = parseInt($(document).width() / widthN); if (widthN > 17) { fSize = "inherit" } function interFn() { $(":not(:has(div,li))").filter(function() { return $(this).is('p') || $(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 shallowEqual(object1, object2) { const keys1 = Object.keys(object1); const keys2 = Object.keys(object2); if (keys1.length !== keys2.length) { return false; } for (let index = 0; index < keys1.length; index++) { const val1 = object1[keys1[index]]; const val2 = object2[keys2[index]]; if (val1 !== val2) { return false; } } return true; } var widthZ; var picZ = 0; var imgAr; var newImgAr; $("body").on('touchstart', "#Jscroll-pic", function() { clearInterval(widthZ); $("#Jscroll-ul").remove(); picZ += 1; function interFn() { var preSrc = ""; var preBack = ""; var preData = 0; newImgAr = [] if (picZ == 3) { $("div,a,li,p").each(function() { if (!$(this).parent().is("#Jscroll-ul") && $(this).css("background-image").indexOf("url") > -1) { var _backImg = $(this).css("background-image").replace('url(', "").replace(')', "").replaceAll('"', "").replaceAll('"', "").replaceAll(';', ""); if (_backImg != preBack) { if ($(this).is("a")) { newImgAr.push($(this).clone(true).empty().append("")); } else { newImgAr.push(""); } preBack = _backImg; } } }); $("img").each(function() { var _img = $(this); if (!_img.parent().is("#Jscroll-ul")) { if (_img.is('[src]')) { newImgAr.push(""); } $.each(_img.data(), function(v, i) { if (i != _img.attr('src') && i.toString().indexOf("/") > -1) { newImgAr.push(""); } }); } }); } if (picZ == 1) { $("img").each(function() { var _img = $(this); if (!_img.parent().is("#Jscroll-ul") && _img.outerHeight() > 50) { if (_img.is('[src]')) { newImgAr.push(""); } $.each(_img.data(), function(v, i) { if (i != _img.attr('src') && i.toString().indexOf("/") > -1) { newImgAr.push(""); } }); } }); } if (picZ == 2) { $("a:has(img)").each(function() { var _a = $(this); var _img = _a.find("img:first"); if (!_a.parent().is("#Jscroll-ul") && _img.outerHeight() > 50) { if (_img.is('[src]') && _img.attr('src') != preSrc) { newImgAr.push(_a.clone(true).empty().append("")); preSrc = _img.attr('src'); } if (Object.keys(_img.data()).length > 0 && !shallowEqual(_img.data(), preData)) { $.each(_img.data(), function(v, i) { if (i != _img.attr('src') && i.toString().indexOf("/") > -1) { newImgAr.push(_a.clone(true).empty().append("")); } }); preData = _img.data(); } } }); $("a").each(function() { var _a = $(this); if (!_a.parent().is("#Jscroll-ul")) { if (Object.keys(_a.data()).length > 0 && !shallowEqual(_a.data(), preData)) { $.each(_a.data(), function(v, i) { if (i.toString().indexOf("/") > -1) { newImgAr.push(_a.clone(true).empty().append("")); } }); preData = _a.data(); } } }); } newImgAr = Array.from(new Set(newImgAr)); if (newImgAr.toString() != imgAr.toString()) { imgAr = newImgAr; $("#Jscroll-ul").empty().append(imgAr); $("#Jscroll-ul *").attr("style", "font-size: 0; padding: 0; margin: 0; border: 0;"); $("#Jscroll-ul *").css({ "height": "auto", "width": "100%", "position": "static", "float": "none", "opacity": "1", "display": "block", "object-fit": "contain", "max-height": 2500, "min-height": 50, "background-color": "black", }); $("#Jscroll-ul img").css({ "border": "1px solid gray", }); var isSupportLoading = 'loading' in document.createElement('img'); if (isSupportLoading) { $("#Jscroll-ul img").attr("loading", "lazy"); } $('').appendTo('head'); } var Himg = 0; $("#Jscroll-ul img").each(function(){ Himg += $(this).height(); }); $("#Jscroll-ul").css({ "height": Himg, }); if (xMove == 1) { if ($("#wrap_rotate").width() < $("#Jscroll-ul").height() + 1500) { $("#wrap_rotate").width($("#Jscroll-ul").height() + 1500); } $("#Jscroll-ul").css({ "top": "0", }); } else { if ($("body").height() < $("#Jscroll-ul").height() + 300) { $("body").height($("#Jscroll-ul").height() + 300); } $("#Jscroll-ul").css({ "bottom": "0", }); } } if (picZ < 4) { if (xMove == 1) { $("#wrap_rotate_inner").prepend("