您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
微博新版点击图片或动图自动进入全网页幻灯片(查看大图)模式
// ==UserScript== // @name 微博新版图片/动图自动全屏幻灯片(全兼容版) // @namespace http://tampermonkey.net/ // @version 1.3 // @description 微博新版点击图片或动图自动进入全网页幻灯片(查看大图)模式 // @author YourName // @match https://weibo.com/* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; let lastClickTime = 0; document.body.addEventListener('click', function(e) { let img = e.target.closest('img'); if (!img) return; lastClickTime = Date.now(); }, true); const observer = new MutationObserver((mutationsList) => { for (const mutation of mutationsList) { for (const node of mutation.addedNodes) { if (!(node instanceof HTMLElement)) continue; // 判断是否为弹窗 if ( node.matches?.('[role="dialog"], [aria-modal="true"], .woo-modal, .picture-view-main') || node.querySelector?.('i.picture-tool-bar_icon_3UbxU') ) { if (Date.now() - lastClickTime < 2000) { // 1. 先找普通图片的“查看大图”按钮 let btn = Array.from(node.querySelectorAll('i.picture-tool-bar_icon_3UbxU')) .map(i => i.parentElement) .find(el => el && el.innerText.includes('查看大图') && el.offsetParent !== null); // 2. 如果没找到,再找所有包含“查看大图”文本的按钮/链接/元素(兼容动图) if (!btn) { btn = Array.from(node.querySelectorAll('button,a,div,span')) .find(el => el.innerText && el.innerText.includes('查看大图') && el.offsetParent !== null); } if (btn) { btn.click(); } } } } } }); observer.observe(document.body, { childList: true, subtree: true }); })();