// ==UserScript== // @name 手机看图、小说适配 // @namespace http://tampermonkey.net/ // @version 9.439 // @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'; if ($('.JqScroll').length > 0) { return } var winWidth = window.innerWidth; var winHeight = window.innerHeight; var winW; if (winWidth > winHeight) { winW = winHeight * 0.9; } else { winW = winWidth; } var width = winW * 0.125; var height = winW * 0.1; var top = winHeight * 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; margin: 0; border: 0; background-color: black;" var aScss = "opacity: 0.7; border-radius: " + (width * 0.1) + "px;cursor: pointer; 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("") .append("") .append("") .append("") .append("") .append("") .append("") .append("") .append("") .append("") .append("") $("").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 = $('
', { 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 = winHeight; 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; $("#Jscroll-ul").css({ "padding": "0 0 1500px 0", }); $("#wrap_rotate").css({ "min-width": $("#wrap_rotate_inner").outerHeight() + 1500, }); window.scrollTo(0, 0); }, 200); } else { $("#Jscroll-rotate").css("color", "white"); xMove = 0; $("#Jscroll-ul").css({ "padding": "0 0 800px 0", }); 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() { $("p:not(.word-text-big),strong:not(.word-text-big),span:not(.word-text-big)").css({ "background-color": "black", "color": "white", "font-size": fSize, "line-height": "normal", }).addClass("word-text-big"); $(":not(:has(div,li),.word-text-big)").filter(function() { return $(this).clone().children().remove().end().text().length > 100; }).css({ "background-color": "black", "color": "white", "font-size": fSize, "line-height": "normal", }).addClass("word-text-big"); } 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; }); $("body").on('click', ".word-text-big", function(e) { if ($(this).parents(".word-text-big").length == 0) { var touchX = e.clientX; var touchY = e.clientY; var howH = 0.9; var scrollH = 0.5; if (xMove == 1) { window.scrollBy(winWidth * howH * (touchX > winWidth * scrollH ? 1 : -1), 0); } else { window.scrollBy(0, winHeight * howH * (touchY > winHeight * scrollH ? 1 : -1)); } } }); var picwh = 100; $("body").on('touchstart', "#Jscroll-picwh", function() { picwh += 100; $("#Jscroll-picwh").val(picwh); $("#Jscroll-ul img:visible").each(function() { if (this.naturalWidth) { if (this.naturalWidth < picwh || this.naturalHeight < picwh) { $(this).hide(); } } }); }); var timeout_8; $("body").on('touchstart', '#Jscroll-picwh', function() { timeout_8 = setTimeout(function() { picwh = 100; $("#Jscroll-picwh").val(picwh); $("#Jscroll-ul img").filter(function() { return this.naturalWidth; }).show(); $("#Jscroll-ul img:visible").each(function() { if (this.naturalWidth) { if (this.naturalWidth < picwh || this.naturalHeight < picwh) { $(this).hide(); } } }); }, 500); }).on('touchend touchmove', '#Jscroll-picwh', function() { clearTimeout(timeout_8); }); function clearBlank(urlB) { return urlB.trim().split(/(?<=[.](xbm|tif|pjp|svgz|jpg|jpeg|ico|tiff|gif|svg|jfif|webp|png|bmp|pjpeg|avif))[?]/)[0]; } $("body").on('click', "#Jscroll-ul a", function() { if (Dscroll % 2 != 0) { Dscroll += 1; $("#Jscroll-Ju").css("color", "white"); clearInterval(timeDown); } }); var widthZ; var downImg; var picZ = 0; $("body").on('touchstart', "#Jscroll-pic", function() { 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()); var _imgStr = ""; $.each(dataObj, function(v, i) { i = i.toString(); if (/[/?]/.test(i) && (!/[.](gif)([^a-z]|$)/i.test(i) || _img.outerHeight() > 180)) { i = clearBlank(i); _imgStr = "" + _img.attr("alt") + "
"; } else { _pStr = _img.attr("title") ? "" + _img.attr("title") + "
" : ""; } if (_a.length != 0) { var _href = _a.attr("href") ? "href='" + _a.attr("href") + "'" : ""; var _onclick = _a.attr("onclick") ? _a.attr("onclick") : ""; newImgAr.push("" + _imgStr + _pStr + ""); preArr.push(i); } else { newImgAr.push(_imgStr, _pStr); } } } }); if (picZ == 2 && _img.is("a")) { var _href = _img.attr("href") ? "href='" + _img.attr("href") + "'" : ""; var _onclick = _img.attr("onclick") ? _img.attr("onclick") : ""; var _text = _img.attr("title") ? _img.attr("title") : _img.text(); newImgAr.push("" + _text + ""); } } }); newImgAr = Array.from(new Set(newImgAr)); if (newImgAr.toString() != imgAr.toString()) { var newArrEx = newImgAr.filter(function(n) { return imgAr.indexOf(n) == -1 }); $("#Jscroll-ul").append(newArrEx); 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(); }); $("#Jscroll-ul img").on("load", function() { var natuW = this.naturalWidth; var natuH = this.naturalHeight; if (natuW < picwh || natuH < picwh) { $(this).hide(); } else { if (_numH < 6) { _allH += natuW < natuH ? natuW : natuH; _numH += 1; } if (_numH == 5) { picwh = parseInt(_allH * 0.6 / _numH / 100) * 100; if (picwh < 100) { picwh = 100; } $("#Jscroll-picwh").val(picwh); $("#Jscroll-ul img:visible").each(function() { if (this.naturalWidth) { if (this.naturalWidth < picwh || this.naturalHeight < picwh) { $(this).hide(); } } }); } } }); imgAr = newImgAr; } } clearInterval(widthZ); clearInterval(downImg); $("#Jscroll-ul").remove(); picZ += 1; if (picZ < 4) { if (xMove == 1) { $("#wrap_rotate_inner").prepend("