您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
妖火图片加强!!!
当前为
// ==UserScript== // @name 妖火图片加强 // @namespace http://yaohuo.me/ // @version 0.1 // @description 妖火图片加强!!! // @require https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js // @match https://yaohuo.me/bbs-** // @match https://www.yaohuo.me/bbs-** // @icon https://www.google.com/s2/favicons?sz=64&domain=yaohuo.me // @author 夜猎 // ==/UserScript== (function() { 'use strict'; $(document).ready(function() { var defaultImgSize = 100; var maxPreviewSize = 9999; // function closeImage() { // imageContainer.style.display = 'none'; // document.removeEventListener('keydown', keydownHandler); // imageContainer.removeEventListener('wheel', wheelHandler); // } var imageContainer = document.createElement('div'); imageContainer.classList.add('imageContainer'); imageContainer.style.display = 'none'; imageContainer.style.backgroundColor = 'rgba(0, 0, 0, 0.5)'; imageContainer.style.borderRadius = '10px'; imageContainer.style.position = 'fixed'; imageContainer.style.top = '50%'; imageContainer.style.left = '50%'; imageContainer.style.transform = 'translate(-50%, -50%)'; imageContainer.style.zIndex = '9999'; imageContainer.style.padding = '20px'; document.body.appendChild(imageContainer); var imageElement = document.createElement('img'); imageElement.style.maxWidth = maxPreviewSize + 'px'; imageElement.style.maxHeight = maxPreviewSize + 'px'; imageContainer.appendChild(imageElement); // function keydownHandler(event) { // if (event.key === 'Escape') { // closeImage(); // } // } function wheelHandler(event) { event.preventDefault(); var currentWidth = parseFloat(imageElement.style.width) || imageElement.width; var scaleFactor = event.deltaY > 0 ? 0.9 : 1.1; var newWidth = currentWidth * scaleFactor; imageElement.style.width = newWidth + 'px'; imageElement.style.height = 'auto'; } var thirdImages = document.querySelectorAll('.content img'); for (var i = 0; i < thirdImages.length; i++) { var thirdImage = thirdImages[i]; thirdImage.style.maxHeight = '780px'; if (thirdImage.parentNode.tagName == 'A' && thirdImage.parentNode.href.indexOf('https://yaohuo.me/bbs/upload/') == 0) { thirdImage.parentNode.onclick = function() { return false; }; } thirdImage.onclick = function() { debugger; var isZoomed = imageContainer.style.display !== 'none'; // 使用toggle函数根据当前样式来决定添加还是移除max-height属性 if (this.style.maxHeight) { this.style.maxHeight = null; // 移除max-height } else { this.style.maxHeight = '780px'; // 添加max-height var distanceToTop = this.offsetTop; // 计算新的滚动位置,使图片位于视口偏下50px处 var newScrollPosition = distanceToTop + 150; window.scrollTo({ top: newScrollPosition, behavior: "smooth" }); //this.scrollIntoView({behavior: "smooth"}); } // if (isZoomed) { // closeImage(); // } else { // imageElement.src = this.src; // imageContainer.style.display = 'block'; // imageElement.style.width = defaultImgSize + 'px'; // document.addEventListener('keydown', keydownHandler); // var previewWidth = Math.min(maxPreviewSize, this.width); // var previewHeight = Math.min(maxPreviewSize, this.height); // imageElement.style.width = previewWidth + 'px'; // imageElement.style.height = previewHeight + 'px'; // //imageContainer.style.marginLeft = '-' + (previewWidth / 2) + 'px'; // //imageContainer.style.marginTop = '-' + (previewHeight / 2) + 'px'; // imageContainer.addEventListener('wheel', wheelHandler); // } }; } }); })();