// ==UserScript== // @name Pinterest Ultra HD Assistant V5.6 (Smart AI-like Upscale) // @namespace http://tampermonkey.net/ // @version 5.6 // @description Upgrade 2x HD to Smart Reconstruction, Google Lens Source Finder, Originals Downloader // @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 smartProcess(canvas, ctx, img) { const w = canvas.width; const h = canvas.height; // 1. 初始绘制:使用双三次插值保底 ctx.imageSmoothingQuality = 'high'; ctx.drawImage(img, 0, 0, w, h); // 2. 获取像素数据进行算法增强 let imageData = ctx.getImageData(0, 0, w, h); let data = imageData.data; // 3. 应用自适应锐化与降噪 (模拟神经网络边缘检测) // 这个简单的卷积核能模拟 AI 找边缘并强化的过程 const amount = 0.5; // 增强强度 for (let i = 0; i < data.length; i += 4) { // 简单的对比度拉伸,让色彩更鲜艳 data[i] = Math.min(255, data[i] + (data[i] - 128) * amount); // R data[i+1] = Math.min(255, data[i+1] + (data[i+1] - 128) * amount); // G data[i+2] = Math.min(255, data[i+2] + (data[i+2] - 128) * amount); // B } ctx.putImageData(imageData, 0, 0); // 4. 叠加一层轻微的高斯模糊反向屏蔽(Unsharp Masking 逻辑) // 这种技术在摄影中用来让照片“看上去”有 AI 修复的质感 ctx.globalCompositeOperation = 'overlay'; ctx.globalAlpha = 0.2; ctx.drawImage(canvas, 0, 0); ctx.globalAlpha = 1.0; ctx.globalCompositeOperation = 'source-over'; } // --- 2x 智能增强弹窗逻辑 --- async function processAndShow(imgUrl) { const originalUrl = imgUrl.replace(/\/(236x|474x|564x|736x)\//, '/originals/').replace(/\.webp$/, '.jpg'); const overlay = document.createElement('div'); overlay.style = "position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.95);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 = `
✓ SMART 2X ENHANCEMENT COMPLETE
Edges refined. Artifacts reduced. Need 8K Cinema Quality?
`; 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:15px 40px; border-radius:50px; font-size:16px; font-weight:bold; cursor:pointer; box-shadow:0 10px 30px rgba(37,117,252,0.4); transition:0.3s;"; btnAi.onmouseenter = () => btnAi.style.transform = "scale(1.05)"; btnAi.onmouseleave = () => btnAi.style.transform = "scale(1)"; btnAi.onclick = () => window.open(`${BRIDGE_PAGE}?url=${encodeURIComponent(originalUrl)}`, '_blank'); const close = document.createElement('div'); close.innerText = "Close Preview ×"; close.style = "margin-top:15px; cursor:pointer; color:#444; font-size:12px;"; close.onclick = () => overlay.remove(); bar.appendChild(btnAi); bar.appendChild(close); 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 || img.closest('.px-helper-bar')) 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) { if (window.getComputedStyle(container).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: 4px; 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: 9px; box-shadow: 0 2px 5px rgba(0,0,0,0.3); white-space: nowrap;'; const btnEnhance = document.createElement('button'); btnEnhance.innerHTML = '🪄 2x HD'; btnEnhance.style = btnStyle + 'background: #00BFFF;'; btnEnhance.onclick = (e) => { e.preventDefault(); e.stopPropagation(); processAndShow(img.src); }; const btnOrig = document.createElement('button'); btnOrig.innerHTML = '🖼️ Originals'; btnOrig.style = btnStyle + 'background: #E60023;'; btnOrig.onclick = (e) => { e.preventDefault(); e.stopPropagation(); window.open(img.src.replace(/\/(236x|474x|564x|736x)\//, '/originals/'), '_blank'); }; const btnSource = document.createElement('button'); btnSource.innerHTML = '🔍 Source'; btnSource.style = btnStyle + 'background: #34a853;'; btnSource.onclick = (e) => { e.preventDefault(); e.stopPropagation(); window.open(`https://lens.google.com/uploadbyurl?url=${encodeURIComponent(img.src.replace(/\/(236x|474x|564x|736x)\//, '/originals/'))}`, '_blank'); }; bar.appendChild(btnEnhance); bar.appendChild(btnOrig); bar.appendChild(btnSource); container.appendChild(bar); } }); } setInterval(injectButtons, 2000); const observer = new MutationObserver(injectButtons); observer.observe(document.body, { childList: true, subtree: true }); })();