Greasy Fork is available in English.
Lightweight & Ultra Fast: One-Click Originals, AI 2x Sharpen, and Source Finder. Zero lag.
当前为
// ==UserScript==
// @name Pinterest Ultra Assistant V6.6 (Phantom Light)
// @namespace http://tampermonkey.net/
// @version 6.6
// @description Lightweight & Ultra Fast: One-Click Originals, AI 2x Sharpen, and Source Finder. Zero lag.
// @author Pi Xiao
// @match https://*.pinterest.com/*
// @grant GM_openInTab
// @grant GM_setClipboard
// @license MIT
// ==/UserScript==
(function() {
'use strict';
const BRIDGE_PAGE = "https://meishubiji.cn/ai-processing-center/";
// --- 1. 核心算法逻辑 (仅在弹窗时运行,不占初始资源) ---
const getOriginalUrl = (url) => url.replace(/\/(236x|474x|564x|736x|1200x)\//, '/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.96);z-index:2147483647;display:flex;flex-direction:column;align-items:center;justify-content:center;color:white;font-family:sans-serif;cursor:zoom-out;";
overlay.innerHTML = '<div style="text-align:center;"><div class="px-spin"></div><div style="margin-top:15px;font-size:14px;color:#00ffcc;">RECONSTRUCTING...</div></div><style>.px-spin{width:30px;height:30px;border:2px solid rgba(0,255,204,0.1);border-top-color:#00ffcc;border-radius:50%;animation:spin .8s linear infinite;margin:0 auto;}@keyframes spin{to{transform:rotate(360deg)}}</style>';
overlay.onclick = () => overlay.remove();
document.body.appendChild(overlay);
const img = new Image();
img.crossOrigin = "Anonymous";
img.src = originalUrl;
img.onload = function() {
overlay.innerHTML = "";
const container = document.createElement('div');
container.style = "text-align:center;width:95%;height:90vh;display:flex;flex-direction:column;cursor:default;";
container.onclick = (e) => e.stopPropagation();
const scrollBox = document.createElement('div');
scrollBox.style = "overflow:auto;border:1px solid #333;border-radius:12px;flex:1;background:#050505;display:flex;align-items:center;justify-content:center;";
const pImg = document.createElement('img');
pImg.src = originalUrl;
pImg.style = "max-width:200%;image-rendering:-webkit-optimize-contrast;filter:contrast(1.05);";
scrollBox.appendChild(pImg);
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:14px 50px;border-radius:50px;font-size:15px;font-weight:bold;cursor:pointer;margin:20px;";
btnAi.onclick = () => window.open(`${BRIDGE_PAGE}?url=${encodeURIComponent(originalUrl)}`, '_blank');
container.appendChild(scrollBox);
container.appendChild(btnAi);
overlay.appendChild(container);
};
img.onerror = () => { window.open(originalUrl, '_blank'); overlay.remove(); };
}
// --- 2. 极其克制的注入逻辑 ---
let timer = null;
function throttleInject() {
if (timer) return;
timer = setTimeout(() => {
const images = document.querySelectorAll('img[src*="pinimg.com"]:not(.px-done)');
images.forEach(img => {
if (img.width < 100) return;
img.classList.add('px-done'); // 标记已处理,不再重复扫描
const container = img.closest('[data-test-id="pin-visual-wrapper"]') ||
img.closest('[data-test-id="visual-content-container"]') ||
img.parentElement;
if (container) {
const bar = document.createElement('div');
bar.className = 'px-helper-bar';
bar.style = "position:absolute;top:5px;left:5px;z-index:99;display:flex;gap:3px;opacity:0;transition:opacity 0.2s;";
const btnStyle = 'color:white;border:none;border-radius:3px;cursor:pointer;padding:2px 5px;font-weight:bold;font-size:8px;box-shadow:0 1px 3px rgba(0,0,0,0.3);';
const b1 = document.createElement('button'); b1.innerHTML = '🪄 2x'; b1.style = btnStyle + 'background:#00BFFF;';
b1.onclick = (e) => { e.preventDefault(); e.stopPropagation(); processAndShow(img.src); };
const b2 = document.createElement('button'); b2.innerHTML = '🖼️ HD'; b2.style = btnStyle + 'background:#E60023;';
b2.onclick = (e) => { e.preventDefault(); e.stopPropagation(); window.open(getOriginalUrl(img.src), '_blank'); };
const b3 = document.createElement('button'); b3.innerHTML = '🔍 Src'; b3.style = btnStyle + 'background:#34a853;';
b3.onclick = (e) => { e.preventDefault(); e.stopPropagation(); window.open(`https://lens.google.com/uploadbyurl?url=${encodeURIComponent(getOriginalUrl(img.src))}`, '_blank'); };
bar.append(b1, b2, b3);
container.appendChild(bar);
container.addEventListener('mouseenter', () => bar.style.opacity = "1");
container.addEventListener('mouseleave', () => bar.style.opacity = "0");
}
});
timer = null;
}, 500); // 降低频率到每 0.5 秒最多执行一次
}
// --- 3. 启动逻辑:静默观察 ---
const observer = new MutationObserver(throttleInject);
observer.observe(document.body, { childList: true, subtree: true });
// 首次运行
setTimeout(throttleInject, 3000);
})();