您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
去除图片延迟加载,直接显示原图片
当前为
- // ==UserScript==
- // @name Disable Wechat Images Lazyload
- // @name:zh-CN 微信公众号去除图片延迟加载
- // @description Disable Wechat Images Lazyload, Show Origin Images Directly
- // @description:zh-CN 去除图片延迟加载,直接显示原图片
- // @namespace https://www.runningcheese.com
- // @version 0.3
- // @author RunningCheese
- // @match https://mp.weixin.qq.com/s/*
- // @match https://mp.weixin.qq.com/s?__biz=*
- // @run-at document-start
- // @require https://code.jquery.com/jquery-3.3.1.min.js
- // @icon https://t1.gstatic.cn/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=https://mp.weixin.qq.com
- // @license MIT
- // ==/UserScript==
- var $ = window.jQuery;
- // 处理图片懒加载
- function processLazyImages() {
- $('img').each(function(){
- var dataSrc = $(this).attr('data-src');
- if (dataSrc){
- $(this).attr('src', dataSrc);
- $(this).removeAttr('data-src');
- $(this).removeAttr('data-type');
- $(this).removeAttr('data-w');
- $(this).removeAttr('data-ratio');
- $(this).removeAttr('data-fail');
- }
- });
- }
- // 移除URL中的懒加载参数
- function removeWxLazyParam() {
- const links = document.querySelectorAll('a');
- links.forEach(link => {
- if (link.href && link.href.includes('wx_lazy=1')) {
- link.href = link.href.replace('wx_lazy=1', '');
- }
- });
- }
- // 监听DOM变化,处理动态加载的内容
- function observeDOMChanges() {
- const observer = new MutationObserver(function(mutations) {
- processLazyImages();
- removeWxLazyParam();
- });
- observer.observe(document.body, {
- childList: true,
- subtree: true
- });
- }
- // 页面加载完成后执行
- $(document).ready(function() {
- // 立即执行一次
- processLazyImages();
- removeWxLazyParam();
- // 再延迟执行一次,确保处理完所有图片
- setTimeout(function(){
- processLazyImages();
- removeWxLazyParam();
- // 开始监听DOM变化
- observeDOMChanges();
- }, 1000);
- });
- // 替换HTML内容中的懒加载属性
- document.addEventListener('DOMContentLoaded', function() {
- const htmlContent = document.body.innerHTML;
- document.body.innerHTML = htmlContent.replace(/wx_lazy=1/g, '').replace(/data-src/g, 'src');
- });