// ==UserScript== // @name Pinterest Ultra HD Assistant V5.3 (Ultra Stable) // @namespace http://tampermonkey.net/ // @version 5.3 // @description 极致稳定性优化:双重监听+全量补漏,确保按钮 100% 出现 // @author Pi Xiao // @match https://*.pinterest.com/* // @grant GM_openInTab // @downloadURL none // ==/UserScript== (function() { 'use strict'; // 你的跳转中心地址 const BRIDGE_PAGE = "https://meishubiji.cn/ai-processing-center/"; // --- 工具函数 --- function getOriginalUrl(url) { return url.replace(/\/(236x|474x|564x|736x)\//, '/originals/').replace(/\.webp$/, '.jpg'); } // --- 核心显示逻辑 (processAndShow 同前,保持稳定) --- async function processAndShow(imgUrl) { const originalUrl = getOriginalUrl(imgUrl); const overlay = document.createElement('div'); overlay.style = "position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.9);z-index:100000;display:flex;flex-direction:column;align-items:center;justify-content:center;color:white;font-family:sans-serif;cursor:zoom-out;"; overlay.innerHTML = '
✓ 2x Sharpening Done. Still blurry? Try 8K Neural Reconstruction:
`; const btnAi = document.createElement('button'); btnAi.innerHTML = '🚀 Launch AI 8K Engine'; btnAi.style = "background:linear-gradient(45deg, #6a11cb 0%, #2575fc 100%); color:white; border:none; padding:12px 30px; border-radius:50px; font-size:16px; font-weight:bold; cursor:pointer;"; btnAi.onclick = () => window.open(`${BRIDGE_PAGE}?url=${encodeURIComponent(originalUrl)}`, '_blank'); bar.appendChild(btnAi); container.appendChild(scrollBox); container.appendChild(bar); overlay.appendChild(container); }; img.onerror = () => { window.open(originalUrl, '_blank'); overlay.remove(); }; } // --- 注入逻辑:增强版 --- function injectButtons() { // 查找 Pinterest 所有可能的图片容器 const images = document.querySelectorAll('img[src*="pinimg.com"]'); images.forEach(img => { // 排除掉头像和极小的图标 if (img.width < 100) return; // 寻找最贴近的 Pin 容器 const container = img.closest('[data-test-id="pin-visual-wrapper"]') || img.closest('[data-test-id="visual-content-container"]') || img.closest('.XiG') || img.parentElement; if (container && !container.querySelector('.px-helper-bar')) { // 确保容器可以定位 const style = window.getComputedStyle(container); if (style.position === 'static') { container.style.position = 'relative'; } const bar = document.createElement('div'); bar.className = 'px-helper-bar'; bar.style = `position: absolute; top: 10px; left: 10px; z-index: 99; display: flex; gap: 6px; opacity: 0; transition: 0.3s; pointer-events: auto;`; // 鼠标移入容器显示,移出隐藏 container.addEventListener('mouseenter', () => bar.style.opacity = "1"); container.addEventListener('mouseleave', () => bar.style.opacity = "0"); const btnStyle = 'color: white; border: none; border-radius: 4px; cursor: pointer; padding: 4px 8px; font-weight: bold; font-size: 11px; box-shadow: 0 2px 5px rgba(0,0,0,0.3);'; const btnEnhance = document.createElement('button'); btnEnhance.innerHTML = '🪄 2x增强'; btnEnhance.style = btnStyle + 'background: #00BFFF;'; btnEnhance.onclick = (e) => { e.preventDefault(); e.stopPropagation(); processAndShow(img.src); }; const btnOrig = document.createElement('button'); btnOrig.innerHTML = '🖼️ 原图'; btnOrig.style = btnStyle + 'background: #E60023;'; btnOrig.onclick = (e) => { e.preventDefault(); e.stopPropagation(); window.open(getOriginalUrl(img.src), '_blank'); }; bar.appendChild(btnEnhance); bar.appendChild(btnOrig); container.appendChild(bar); } }); } // 1. 动态监听机制 const observer = new MutationObserver(injectButtons); observer.observe(document.body, { childList: true, subtree: true }); // 2. 定时器机制 (保底方案:每2秒检查一次) setInterval(injectButtons, 2000); // 3. 初次运行 injectButtons(); })();