您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
把图片的最大宽度缩小50%
// ==UserScript== // @name 虎扑楼中图片缩小 // @namespace http://tampermonkey.net/ // @version 0.7 // @description 把图片的最大宽度缩小50% // @author Rod // @match https://bbs.hupu.com/* // @grant none // ==/UserScript== (function () { 'use strict'; window.addEventListener('scroll', () => { imgsmall() }) function imgsmall() { let arr = document.querySelectorAll("[class*=reply-list-content] img,.main-post-info img") for (let item of arr) { if (isVisible(item)) item.style.maxWidth = '50%' } } function isVisible(elem) { let coords = elem.getBoundingClientRect(); let windowHeight = document.documentElement.clientHeight; // 顶部元素边缘可见或底部元素边缘可见 let topVisible = coords.top > -250 && coords.top < windowHeight; let bottomVisible = coords.bottom < windowHeight + 250 && coords.bottom > 0; return topVisible || bottomVisible; } })();