// ==UserScript== // @name 禁止 Web 延迟加载图片(优化版 - 支持滑动加载) // @name:en Disable Web Lazy Loading Images (Enhanced Version - Supports Scroll Loading) // @description 在 Web 页面中直接显示图片,禁止延迟加载,支持滑动加载图片 // @description:en Display images directly on the web page, prohibit lazy loading, and support scroll-loaded images. // @version 0.5 // @author DUN // @match *://*/* // @run-at document-start // @namespace https://greasyfork.org/users/662094 // @downloadURL none // ==/UserScript== (function() { // 禁止图片延迟加载 function disableLazyLoad() { var images = document.querySelectorAll('img[data-src]'); images.forEach(function(img) { img.setAttribute('src', img.getAttribute('data-src')); img.removeAttribute('data-src'); }); } // 使用 IntersectionObserver 监视图片加载 var observer = new IntersectionObserver(function(entries, observer) { entries.forEach(function(entry) { if (entry.isIntersecting) { var img = entry.target; if (img.hasAttribute('data-src')) { img.setAttribute('src', img.getAttribute('data-src')); img.removeAttribute('data-src'); observer.unobserve(img); // 只加载一次后停止观察 } } }); }); // 获取所有需要处理的图片元素 var images = document.querySelectorAll('img[data-src]'); images.forEach(function(img) { observer.observe(img); }); // 初始禁止延迟加载 disableLazyLoad(); })();