// ==UserScript== // @name 微信公众号图集一键展示 // @namespace http://tampermonkey.net/ // @version 2024.10.17 // @description 让世界更美好! // @author sbdx // @license GPLv3 // @match https://mp.weixin.qq.com/s/* // @match https://mp.weixin.qq.com/s?* // @icon https://www.google.com/s2/favicons?sz=64&domain=qq.com // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; //图集页面的修改 function showAlbum() { console.log("开始打开图集事件......"); var html=""; window.picture_page_info_list.forEach((i)=>{ let url=i.cdn_url.replace("/640?","/0?"); html+=`
`; }); document.getElementById('js_article').innerHTML=(html); } //普通页面图片替换为高清图片 function replaceHighQualityImage() { let img=document.querySelector(".rich_media_content").getElementsByTagName("img"); img.forEach((i)=>{ let url=i.src.replace("/640?","/0?").replace("tp=webp","tp=jpeg"); console.log(url); i.dataset.src=url; i.src=url; window.scrollTo(0, document.body.scrollHeight); window.scrollTo(0, 0); }); } //优化图片布局显示 function formatDisplayImage() { let html=''; let svg_imgs=document.querySelectorAll("[data-lazy-bgimg]"); svg_imgs.forEach((i)=>html+=`

`); let imgs=document.getElementById('js_content').getElementsByTagName("img"); imgs.forEach((i)=>console.log(html+=`

`));html=html.replace("/640?","/0?").replace("tp=webp","tp=jpeg"); document.getElementById("js_content").innerHTML=html; } if(document.getElementById('img_swiper_placeholder')) { let btn=document.createElement("button"); btn.innerText="打开图集"; btn.addEventListener('click',function(){ showAlbum(); document.getElementById("js_article").style.display='block'; document.getElementById("js_article").style.height='inherit'; document.getElementById("js_article").style.maxHeight='none'; document.getElementById("js_article").style.overflow='scroll'; }); document.querySelector(".rich_media_title").append(btn); console.log("确认过眼神,是对的人!"); } else if(document.getElementById('js_content')) { let btn=document.createElement("button"); btn.innerText="切换高清图"; btn.style.fontSize="12px"; btn.style.widht="80px"; btn.style.height="20px"; btn.addEventListener('click',function(){ replaceHighQualityImage(); document.getElementById("js_article").style.display='block'; document.getElementById("js_article").style.height='inherit'; document.getElementById("js_article").style.maxHeight='none'; document.getElementById("js_article").style.overflow='scroll'; }); let btn2=document.createElement("button"); btn2.innerText="优化布局显示"; btn2.style.fontSize="12px"; btn2.style.widht="80px"; btn2.style.height="20px"; btn2.addEventListener('click',function(){ formatDisplayImage(); }); document.querySelector(".rich_media_meta_list").append(btn); document.querySelector(".rich_media_meta_list").append(btn2); } })();