Greasy Fork

Greasy Fork is available in English.

Pinterest Ultra Assistant V6.7 (Instant Fix)

Instant Injection: Works on slow networks & detail pages. One-Click Originals, AI 2x Sharpen, and Source Finder.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Pinterest Ultra Assistant V6.7 (Instant Fix)
// @namespace    http://tampermonkey.net/
// @version      6.7
// @description  Instant Injection: Works on slow networks & detail pages. One-Click Originals, AI 2x Sharpen, and Source Finder.
// @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/";

    // --- 核心逻辑 ---
    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:12px 40px;border-radius:50px;font-size:16px;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(); };
    }

    // --- 3. 增强版注入逻辑 ---
    function injectButtons() {
        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="visual-content-container"]') || 
                              img.closest('[data-test-id="pin-visual-wrapper"]') || 
                              img.parentElement;

            if (container) {
                // 强制确保容器可以相对定位
                if (window.getComputedStyle(container).position === 'static') {
                    container.style.setProperty('position', 'relative', 'important');
                }

                const bar = document.createElement('div');
                bar.className = 'px-helper-bar';
                // 详情页调大一点,首页保持精致
                const isDetail = location.href.includes('/pin/');
                bar.style = `position:absolute; top:${isDetail ? '20px' : '10px'}; left:${isDetail ? '20px' : '10px'}; z-index:2147483640; display:flex; gap:5px; opacity:0; transition:opacity 0.3s; pointer-events:auto;`;
                
                const btnStyle = 'color:white; border:none; border-radius:4px; cursor:pointer; padding:5px 8px; font-weight:bold; font-size:10px; box-shadow:0 2px 8px rgba(0,0,0,0.5); white-space:nowrap;';
                
                const b1 = document.createElement('button'); b1.innerHTML = '🪄 2x HD'; b1.style = btnStyle + 'background:#00BFFF;';
                b1.onclick = (e) => { e.preventDefault(); e.stopPropagation(); processAndShow(img.src); };
                
                const b2 = document.createElement('button'); b2.innerHTML = '🖼️ Originals'; 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 = '🔍 Source'; 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");
            }
        });
    }

    // --- 启动逻辑:不再等待 window.load ---
    // 采用立即运行 + 持续监听模式
    injectButtons();
    const observer = new MutationObserver(injectButtons);
    observer.observe(document.body, { childList: true, subtree: true });
    
    // 每 2 秒全量补漏一次,应对极端网络环境
    setInterval(injectButtons, 2000);

})();