GPicy / Instant AI Object Cleanup - Photo Purify Tool

// ==UserScript==
// @name         Instant AI Object Cleanup - Photo Purify Tool
// @name:es      Limpieza Instantánea de Objetos con IA - Herramienta PuraFoto
// @name:de      Sofortige KI Objektbereinigung - Foto-Reinigungs-Werkzeug
// @name:fr      Nettoyage d'Objet IA Instantané - Outil Purification Photo
// @name:it      Pulizia Oggetti Instantanea con IA - Strumento di Purificazione Foto
// @name:pt      Limpeza Instantânea de Objetos com IA - Ferramenta de Purificação de Fotos
// @name:ru      Мгновенная Очистка Объектов ИИ - Инструмент для Идеальных Фото
// @name:ja      即時AIオブジェクト除去 - 写真ピュリファイツール
// @name:ko      즉각적인 AI 물체 제거 - 사진 정화 도구
// @name:ar      إزالة الكائنات بالذكاء الاصطناعي فوراً - أداة تنقية الصور
// @name:tr      Anında Yapay Zeka Objeleri Temizleme - Fotoğraf Arıtma Aracı
// @name:nl      Directe AI Objecten Opruiming - Foto Zuiveringshulpmiddel
// @name:sv      Omedelbar AI Objektrengöring - Foto Reningsverktyg
// @name:da      Øjeblikkelig AI Genstandsoprydning - Foto Rensningsværktøj
// @name:zh      AI即刻物件移除 - 照片净化工具
// @name:zh-TW   AI即時物體移除 - 照片淨化工具
// @description  Sharpen your visuals by swiftly erasing unwanted elements. Enhance your photos with this smart AI tool that removes objects with ease.
// @description:es  Afile tus visuales eliminando rápidamente elementos no deseados. Mejora tus fotos con esta herramienta inteligente de IA que elimina objetos con facilidad.
// @description:de  Verbessern Sie Ihre Bilder durch schnelles Entfernen unerwünschter Elemente. Dieses smarte KI-Werkzeug entfernt Objekte mühelos.
// @description:fr  Aiguisez vos visuels en effaçant rapidement les éléments indésirables. Améliorez vos photos avec cet outil IA intelligent qui supprime aisément les objets.
// @description:it  Affina i tuoi visual eliminando con rapidità gli elementi indesiderati. Rifinisci le tue foto con questo strumento intelligente AI che rimuove oggetti facilmente.
// @description:pt  Aperfeiçoe suas imagens apagando rapidamente elementos indesejados. Melhore suas fotos com esta ferramenta inteligente de IA que remove objetos com facilidade.
// @description:ru  Отточите ваши визуальные образы, быстро стирая ненужные элементы. С этим умным инструментом ИИ вы легко улучшите ваши фотографии, удалив объекты.
// @description:ja  不要な要素を迅速に消去してビジュアルを研ぎ澄ませましょう。このスマートAIツールで手軽にオブジェクトを消去して写真を強化。
// @description:ko  원하지 않는 요소를 신속하게 지워 시각을 선명하게 만드세요. 이 스마트 AI 도구를 사용하여 불필요한 물체를 쉽게 제거하고 사진을 향상시키세요.
// @description:ar  حدد رؤيتك بسرعة بإزالة العناصر غير المرغوب فيها. قم بتحسين صورك مع هذه الأداة الذكية التي تزيل الأجسام بسهولة.
// @description:tr  İstenmeyen unsurları hızla silerek görsellerinizi keskinleştirin. Obje kaldırma özelliğiyle fotoğraflarınızı bu akıllı AI araç ile iyileştirin.
// @description:nl  Verhelder uw visuals door ongewenste elementen snel te wissen. Verbeter uw foto's met deze slimme AI-tool die objecten gemakkelijk verwijdert.
// @description:sv  Förbättra dina visuella genom att snabbt ta bort oönskade element. Förbättra dina bilder med detta intelligenta AI-verktyg som enkelt tar bort objekt.
// @description:da  Forbedre dine visuelle billeder ved hurtigt at fjerne uønskede elementer. Forbedre dine fotos med dette smarte AI-værktøj, der nemt fjerner genstande.
// @description:zh  快速擦除不需要的元素来提升您的视觉效果。 这个智能AI工具可以轻松移除物体,优化您的照片。
// @description:zh-TW 快速擦掉不想要的元素,提升視覺效果。這個智慧AI工具能輕鬆移除物體,讓您的照片更完美。
// @namespace    http://gpicy.com
// @author       gpicy
// @version      1.4.9
// @match        *://*/*
// @supportURL   https://gpicy.com/en-US/object-removal?utm_source=openuserjs
// @grant        none
// @run-at       document-start
// @license      Apache-2.0
// ==/UserScript==

(function() {
    const floatingMenu = document.createElement('div');
    floatingMenu.style.cssText = `
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, rgba(132, 16, 145, 0.45), rgba(222, 0, 114, 0.45));
    padding: 10px;
    border-radius: 0 5px 5px 0;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    z-index: 10000;
    `;

    const closeButton = document.createElement('div');
    closeButton.innerHTML = `×`; // "×" symbol
    closeButton.style.cssText = `
    position: absolute;
    top: 0;
    right: 0;
    width: 30px;
    height: 30px;
    margin-right: -10px;
    margin-top: -10px;
    border-radius: 15px; /* Makes it round */
    background-color: #FFF;
    color: #000;
    text-align: center;
    line-height: 30px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    `;
    closeButton.onclick = function() {
        document.body.removeChild(floatingMenu);
    };

    const menuTranslations = {
        'en': {
            'Image OCR': '🖼️ Image OCR',
            'PDF OCR': '📄 PDF OCR',
            'Lossless Image Enlarge': '🔍 Lossless Image Enlarge',
            'Background Removal': '🚫 Background Removal',
            'Object Removal': '🧹 Object Removal',
            'Photo Colorization': '🎨 Photo Colorization',
            'Portrait Restoration': '👥 Portrait Restoration'
        },
        'fr': { // French
            'Image OCR': '🖼️ OCR d\'Image',
            'PDF OCR': '📄 OCR de PDF',
            'Lossless Image Enlarge': '🔍 Agrandissement d\'Image Sans Perte',
            'Background Removal': '🚫 Suppression de l\'Arrière-plan',
            'Object Removal': '🧹 Retrait d\'Objet',
            'Photo Colorization': '🎨 Colorisation de Photo',
            'Portrait Restoration': '👥 Restauration de Portrait'
        },
        'de': { // German
            'Image OCR': '🖼️ Bild OCR',
            'PDF OCR': '📄 PDF OCR',
            'Lossless Image Enlarge': '🔍 Verlustfreie Bildvergrößerung',
            'Background Removal': '🚫 Hintergrund Entfernen',
            'Object Removal': '🧹 Objektentfernung',
            'Photo Colorization': '🎨 Fotokolorierung',
            'Portrait Restoration': '👥 Porträtrestaurierung'
        },
        'es': { // Spanish
            'Image OCR': '🖼️ OCR de Imagen',
            'PDF OCR': '📄 OCR de PDF',
            'Lossless Image Enlarge': '🔍 Ampliación de Imagen Sin Pérdida',
            'Background Removal': '🚫 Eliminación de Fondo',
            'Object Removal': '🧹 Eliminación de Objeto',
            'Photo Colorization': '🎨 Colorización de Fotos',
            'Portrait Restoration': '👥 Restauración de Retrato'
        },
        'it': { // Italian
            'Image OCR': '🖼️ OCR Immagine',
            'PDF OCR': '📄 OCR PDF',
            'Lossless Image Enlarge': '🔍 Ingrandimento Immagine Senza Perdite',
            'Background Removal': '🚫 Rimozione dello Sfondo',
            'Object Removal': '🧹 Rimozione Oggetto',
            'Photo Colorization': '🎨 Colorazione Foto',
            'Portrait Restoration': '👥 Restauro Ritratto'
        },
        'pt': { // Portuguese
            'Image OCR': '🖼️ OCR de Imagem',
            'PDF OCR': '📄 OCR de PDF',
            'Lossless Image Enlarge': '🔍 Ampliação de Imagem sem Perda',
            'Background Removal': '🚫 Remoção de Fundo',
            'Object Removal': '🧹 Remoção de Objeto',
            'Photo Colorization': '🎨 Coloração de Foto',
            'Portrait Restoration': '👥 Restauração de Retrato'
        },
        'ja': { // Japanese
            'Image OCR': '🖼️ 画像OCR',
            'PDF OCR': '📄 PDF OCR',
            'Lossless Image Enlarge': '🔍 ロスレス画像拡大',
            'Background Removal': '🚫 背景削除',
            'Object Removal': '🧹 オブジェクト削除',
            'Photo Colorization': '🎨 写真着色',
            'Portrait Restoration': '👥 ポートレート修復'
        },
        'nl': { // Dutch
            'Image OCR': '🖼️ Afbeelding OCR',
            'PDF OCR': '📄 PDF OCR',
            'Lossless Image Enlarge': '🔍 Verliesvrije Afbeelding Vergroten',
            'Background Removal': '🚫 Achtergrond Verwijderen',
            'Object Removal': '🧹 Object Verwijderen',
            'Photo Colorization': '🎨 Foto Inkleuren',
            'Portrait Restoration': '👥 Portret Restauratie'
        },
        'ru': { // Russian
            'Image OCR': '🖼️ OCR изображений',
            'PDF OCR': '📄 OCR PDF',
            'Lossless Image Enlarge': '🔍 Безубыточное Увеличение Изображения',
            'Background Removal': '🚫 Удаление Фона',
            'Object Removal': '🧹 Удаление Объектов',
            'Photo Colorization': '🎨 Колоризация Фото',
            'Portrait Restoration': '👥 Реставрация Портретов'
        },
        'ko': { // Korean
            'Image OCR': '🖼️ 이미지 OCR',
            'PDF OCR': '📄 PDF OCR',
            'Lossless Image Enlarge': '🔍 손실 없는 이미지 확대',
            'Background Removal': '🚫 배경 제거',
            'Object Removal': '🧹 객체 제거',
            'Photo Colorization': '🎨 사진 채색',
            'Portrait Restoration': '👥 초상화 복원'
        },
        'ar': { // Arabic
            'Image OCR': '🖼️ OCR للصور',
            'PDF OCR': '📄 OCR لملفات PDF',
            'Lossless Image Enlarge': '🔍 تكبير الصورة بدون فقدان',
            'Background Removal': '🚫 إزالة الخلفية',
            'Object Removal': '🧹 إزالة الكائن',
            'Photo Colorization': '🎨 تلوين الصور',
            'Portrait Restoration': '👥 استعادة الصور الشخصية'
        },
        'th': { // Thai
            'Image OCR': '🖼️ OCR ภาพ',
            'PDF OCR': '📄 OCR ไฟล์ PDF',
            'Lossless Image Enlarge': '🔍 ขยายภาพแบบไม่สูญเสียข้อมูล',
            'Background Removal': '🚫 ลบพื้นหลัง',
            'Object Removal': '🧹 ลบวัตถุ',
            'Photo Colorization': '🎨 การตกแต่งสีภาพถ่าย',
            'Portrait Restoration': '👥 การซ่อมแซมภาพเหมือน'
        },
        'zh': { // Simplified Chinese
            'Image OCR': '🖼️ 图像文字识别',
            'PDF OCR': '📄 PDF文字识别',
            'Lossless Image Enlarge': '🔍 无损放大图像',
            'Background Removal': '🚫 背景移除',
            'Object Removal': '🧹 物体移除',
            'Photo Colorization': '🎨 照片上色',
            'Portrait Restoration': '👥 人像修复'
        },
        'zh-TW': { // Traditional Chinese
            'Image OCR': '🖼️ 圖像文字識別',
            'PDF OCR': '📄 PDF文字識別',
            'Lossless Image Enlarge': '🔍 無損放大圖像',
            'Background Removal': '🚫 背景移除',
            'Object Removal': '🧹 物體移除',
            'Photo Colorization': '🎨 照片上色',
            'Portrait Restoration': '👥 人像修復'
        },

    };

    // Detecting your browser's preferred language
    function detectLanguage() {
        const supportedLangs = Object.keys(menuTranslations);
        const defaultLang = 'en';
        const userLangs = navigator.languages.map(lang => lang.split('-')[0]);
        for (let lang of userLangs) {
            if (supportedLangs.includes(lang)) {
                return lang;
            }
        }
        return defaultLang;
    }

    // Get the language translation of the current user
    const currentLang = detectLanguage();
    const translations = menuTranslations[currentLang];

    // List of features and associated URLs
    const features = [
        { icon: '🖼️', name: 'Image OCR', url: 'https://gpicy.com/en-US/image-ocr?utm_source=openuserjs', desc: 'Image recognition to text' },
        { icon: '📄',   name: 'PDF OCR', url: 'https://gpicy.com/en-US/pdf-ocr?utm_source=openuserjs', desc: 'PDF recognition into text' },
        { icon: '🔍',   name: 'Lossless Image Enlarge', url: 'https://gpicy.com/en-US/lossless-image-enlarge?utm_source=openuserjs', desc: 'Lossless magnification of AI image' },
        { icon: '🚫',   name: 'Background Removal', url: 'https://gpicy.com/en-US/background-removal?utm_source=openuserjs', desc: 'AI Background Removal' },
        { icon: '🧹',   name: 'Object Removal', url: 'https://gpicy.com/en-US/object-removal?utm_source=openuserjs', desc: 'AI Object Removal' },
        { icon: '🎨',   name: 'Photo Colorization', url: 'https://gpicy.com/en-US/photo-colorization?utm_source=openuserjs', desc: 'AI Photo Colorization' },
        { icon: '👥',   name: 'Portrait Restoration', url: 'https://gpicy.com/en-US/portrait-restoration?utm_source=openuserjs', desc: 'AI Portrait Restoration' },
    ];

    floatingMenu.appendChild(closeButton);

    features.forEach(feature => {
        const button = document.createElement('button');
        const translatedName = translations[feature.name] || feature.name;
        button.innerHTML = `${translatedName}`;
        button.style.cssText = `
        display: block;
        width: 100%;
        margin: 5px 0;
        background-color: #FFF;
        color: #000;
        border: none;
        border-radius: 3px;
        padding: 10px;
        cursor: pointer;
        text-align: left;
        transition: transform 0.3s ease, box-shadow 0.3s ease;
        `;

        button.onmouseenter = function() {
            this.style.transform = 'translateX(10px)';
            this.style.boxShadow = '3px 3px 10px rgba(0, 0, 0, 0.2)';
        };

        button.onmouseleave = function() {
            this.style.transform = 'translateX(0)';
            this.style.boxShadow = 'none';
        };

        button.onclick = function() {
            window.open(feature.url, '_blank');
        };

        const tooltip = document.createElement('span');
        tooltip.textContent = feature.desc;
        tooltip.style.cssText = `
            visibility: hidden;
            width: 120px;
            background-color: black;
            color: #fff;
            text-align: center;
            border-radius: 6px;
            padding: 5px 0;
            position: absolute;
            z-index: 1;
            bottom: 125%;
            left: 50%;
            margin-left: -60px;
            opacity: 0;
            transition: opacity 0.3s;
        `;
        button.appendChild(tooltip);

        button.onmouseover = function() {
            tooltip.style.visibility = 'visible';
            tooltip.style.opacity = '1';
        };

        button.onmouseout = function() {
            tooltip.style.visibility = 'hidden';
            tooltip.style.opacity = '0';
        };

        floatingMenu.appendChild(button);
    });

    document.body.appendChild(floatingMenu);
})();