// ==UserScript== // @name Pinterest Ultra HD Assistant V5.4 (Bilingual) // @namespace http://tampermonkey.net/ // @version 5.4 // @description Bilingual UI (English/Chinese), Ultra Stable, One-Click Originals & AI 2x Sharpen // @author Pi Xiao // @match https://*.pinterest.com/* // @grant GM_openInTab // @license MIT // @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'); } // --- 核心显示逻辑 --- 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 = '
🪄 Preparing 2x Sharpening...
'; overlay.onclick = () => overlay.remove(); document.body.appendChild(overlay); const img = new Image(); img.crossOrigin = "Anonymous"; img.src = originalUrl; img.onload = function() { const container = document.createElement('div'); container.style = "text-align:center; width:90%; height:85vh; display:flex; flex-direction:column; cursor:default;"; container.onclick = (e) => e.stopPropagation(); const scrollBox = document.createElement('div'); scrollBox.style = "overflow:auto; border:1px solid #444; border-radius:10px; flex:1; background:#000;"; const previewImg = document.createElement('img'); previewImg.src = originalUrl; previewImg.style = "width:200%; image-rendering: -webkit-optimize-contrast; filter: contrast(1.1);"; scrollBox.appendChild(previewImg); const bar = document.createElement('div'); bar.style = "padding:20px;"; bar.innerHTML = `

✓ 2x Sharpening Done. Still blurry? Try AI 8K Restoration:

`; 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() { const images = document.querySelectorAll('img[src*="pinimg.com"]'); images.forEach(img => { if (img.width < 100) return; 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: 10px; box-shadow: 0 2px 5px rgba(0,0,0,0.3); white-space: nowrap;'; // 按钮 1: 双语增强 const btnEnhance = document.createElement('button'); btnEnhance.innerHTML = '🪄 2x HD / 增强'; btnEnhance.style = btnStyle + 'background: #00BFFF;'; btnEnhance.onclick = (e) => { e.preventDefault(); e.stopPropagation(); processAndShow(img.src); }; // 按钮 2: 双语原图 const btnOrig = document.createElement('button'); btnOrig.innerHTML = '🖼️ Originals / 原图'; 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); } }); } setInterval(injectButtons, 2000); injectButtons(); const observer = new MutationObserver(injectButtons); observer.observe(document.body, { childList: true, subtree: true }); })();