Greasy Fork

Greasy Fork is available in English.

Pinterest Ultra HD Assistant V5.5 (Source Finder)

Bilingual UI, One-Click Originals, AI 2x Sharpen, and Google Lens Source Finder

当前为 2025-12-27 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Pinterest Ultra HD Assistant V5.5 (Source Finder)
// @namespace    http://tampermonkey.net/
// @version      5.5
// @description  Bilingual UI, One-Click Originals, AI 2x Sharpen, and Google Lens Source Finder
// @author       Pi Xiao
// @match        https://*.pinterest.com/*
// @grant        GM_openInTab
// @license      MIT
// ==/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');
    }

    // --- 核心显示逻辑:2x 预览 ---
    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 = '<div style="font-size:14px;color:#00ffcc;">🪄 Preparing 2x Sharpening...</div>';
        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 = `<p style="margin-bottom:15px; font-size:14px; color:#aaa;">✓ 2x Sharpening Done. Still blurry? Try AI 8K Restoration:</p>`;

            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';
                // 稍微向下挪一点,给 3 个按钮留空间
                bar.style = `position: absolute; top: 8px; left: 8px; 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 6px; font-weight: bold; font-size: 9px; box-shadow: 0 2px 5px rgba(0,0,0,0.3); white-space: nowrap;';

                // 按钮 1: 2x 增强
                const btnEnhance = document.createElement('button');
                btnEnhance.innerHTML = '🪄 2x HD';
                btnEnhance.style = btnStyle + 'background: #00BFFF;';
                btnEnhance.title = "Free 2x Sharpen Preview / 免费锐化预览";
                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.title = "View Original High-Res / 查看原图";
                btnOrig.onclick = (e) => { e.preventDefault(); e.stopPropagation(); window.open(getOriginalUrl(img.src), '_blank'); };

                // 按钮 3: 溯源 (新增福利)
                const btnSource = document.createElement('button');
                btnSource.innerHTML = '🔍 Source / 溯源';
                btnSource.style = btnStyle + 'background: #34a853;'; // Google 绿
                btnSource.title = "Find clean source via Google Lens / 谷歌镜头搜原件";
                btnSource.onclick = (e) => { 
                    e.preventDefault(); e.stopPropagation(); 
                    const original = getOriginalUrl(img.src);
                    window.open(`https://lens.google.com/uploadbyurl?url=${encodeURIComponent(original)}`, '_blank');
                };

                bar.appendChild(btnEnhance);
                bar.appendChild(btnOrig);
                bar.appendChild(btnSource);
                container.appendChild(bar);
            }
        });
    }

    setInterval(injectButtons, 2000);
    injectButtons();
    const observer = new MutationObserver(injectButtons);
    observer.observe(document.body, { childList: true, subtree: true });
})();