Note2Link / VSCode Sync for GitHub - Fast Access & Quick Sync

// ==UserScript==
// @name         VSCode Sync for GitHub - Fast Access & Quick Sync
// @name:zh-CN   VSCode GitHub同步 - 快速访问和快速同步工具
// @name:zh-TW   VSCode GitHub同步 - 快速存取和快速同步工具
// @name:ar      مزامنة VSCode مع GitHub - وصول سريع ومزامنة سريعة
// @name:ru      VSCode Синхронизация с GitHub - Быстрый доступ и синхронизация
// @name:fa      همگام‌سازی VSCode با GitHub - دسترسی سریع و همگام‌سازی سریع
// @name:tr      GitHub için VSCode Senkronizasyonu - Hızlı Erişim ve Hızlı Senkronizasyon
// @name:vi      VSCode Sync cho GitHub - Truy cập nhanh và đồng bộ nhanh
// @namespace    http://note2link.com/
// @version      5.0.1
// @author       Note2Link
// @match        https://vscode.dev/*
// @match        https://github.dev/*
// @match        https://*.vscode.dev/*
// @match        https://code.visualstudio.com/*
// @match        https://*.code.visualstudio.com/*
// @match        https://github.com/*
// @match        https://*.github.com/*
// @supportURL   https://note2link.com/en-US/vscode-sync-for-github
// @icon         https://vscode.dev/static/stable/favicon.ico
// @grant        none
// @license      MIT
// @compatible   Chrome
// @compatible   Firefox
// @compatible   Safari
// @compatible   Edge
// @compatible   Opera
// ==/UserScript==

(function () {
    'use strict';

    const translations = {
        'en-US': {
            title: 'Fast Access & Quick Sync VSCode to GitHub',
            subtitle: 'Professional VSCode GitHub Sync Service',
            description: 'Experience seamless sync between VSCode and GitHub with lightning-fast access and enhanced performance.',
            features: ['⚡ Lightning Fast Sync', '🔄 Real-time Backup', '🚀 Enhanced Performance', '🔒 Secure Connection'],
            cta: 'Try Free Now',
            powered: 'Powered by Note2Link'
        },
        'zh-CN': {
            title: 'VSCode到GitHub快速访问和快速同步',
            subtitle: '专业的VSCode GitHub同步服务',
            description: '体验VSCode与GitHub之间的无缝同步,享受闪电般的快速访问和增强性能。',
            features: ['⚡ 闪电般快速同步', '🔄 实时备份', '🚀 增强性能', '🔒 安全连接'],
            cta: '立即免费试用',
            powered: '由 Note2Link 提供支持'
        },
        'zh-TW': {
            title: 'VSCode到GitHub快速存取和快速同步',
            subtitle: '專業的VSCode GitHub同步服務',
            description: '體驗VSCode與GitHub之間的無縫同步,享受閃電般的快速存取和增強效能。',
            features: ['⚡ 閃電般快速同步', '🔄 即時備份', '🚀 增強效能', '🔒 安全連線'],
            cta: '立即免費試用',
            powered: '由 Note2Link 提供支援'
        },
        'ar': {
            title: 'وصول سريع ومزامنة سريعة VSCode مع GitHub',
            subtitle: 'خدمة مزامنة VSCode GitHub المهنية',
            description: 'استمتع بمزامنة سلسة بين VSCode و GitHub مع وصول سريع كالبرق وأداء محسن.',
            features: ['⚡ مزامنة سريعة كالبرق', '🔄 نسخ احتياطي فوري', '🚀 أداء محسن', '🔒 اتصال آمن'],
            cta: 'جرب مجاناً الآن',
            powered: 'مدعوم من Note2Link'
        },
        'ru': {
            title: 'Быстрый доступ и синхронизация VSCode с GitHub',
            subtitle: 'Профессиональный сервис синхронизации VSCode GitHub',
            description: 'Испытайте бесшовную синхронизацию между VSCode и GitHub с молниеносным доступом и улучшенной производительностью.',
            features: ['⚡ Молниеносная синхронизация', '🔄 Резервное копирование в реальном времени', '🚀 Улучшенная производительность', '🔒 Безопасное соединение'],
            cta: 'Попробовать бесплатно',
            powered: 'При поддержке Note2Link'
        },
        'fa': {
            title: 'دسترسی سریع و همگام‌سازی VSCode با GitHub',
            subtitle: 'سرویس حرفه‌ای همگام‌سازی VSCode GitHub',
            description: 'همگام‌سازی یکپارچه بین VSCode و GitHub با دسترسی فوق‌العاده سریع و عملکرد بهبود یافته تجربه کنید.',
            features: ['⚡ همگام‌سازی فوق‌العاده سریع', '🔄 پشتیبان‌گیری لحظه‌ای', '🚀 عملکرد بهبود یافته', '🔒 اتصال امن'],
            cta: 'همین حالا رایگان امتحان کنید',
            powered: 'قدرت گرفته از Note2Link'
        },
        'tr': {
            title: 'VSCode GitHub Hızlı Erişim ve Hızlı Senkronizasyon',
            subtitle: 'Profesyonel VSCode GitHub Senkronizasyon Servisi',
            description: 'VSCode ve GitHub arasında kesintisiz senkronizasyon ile şimşek hızında erişim ve gelişmiş performans deneyimi yaşayın.',
            features: ['⚡ Şimşek Hızında Senkronizasyon', '🔄 Gerçek Zamanlı Yedekleme', '🚀 Gelişmiş Performans', '🔒 Güvenli Bağlantı'],
            cta: 'Şimdi Ücretsiz Deneyin',
            powered: 'Note2Link tarafından desteklenmektedir'
        },
        'vi': {
            title: 'Truy cập nhanh và đồng bộ VSCode với GitHub',
            subtitle: 'Dịch vụ đồng bộ VSCode GitHub chuyên nghiệp',
            description: 'Trải nghiệm đồng bộ liền mạch giữa VSCode và GitHub với truy cập nhanh như chớp và hiệu suất được cải thiện.',
            features: ['⚡ Đồng bộ nhanh như chớp', '🔄 Sao lưu thời gian thực', '🚀 Hiệu suất được cải thiện', '🔒 Kết nối an toàn'],
            cta: 'Dùng thử miễn phí ngay',
            powered: 'Được hỗ trợ bởi Note2Link'
        }
    };

    function detectLanguage() {
        const lang = navigator.language || navigator.userLanguage || 'en-US';
        if (translations[lang]) return lang;
        const baseLang = lang.split('-')[0];
        const supportedLangs = Object.keys(translations);
        for (let supportedLang of supportedLangs) {
            if (supportedLang.startsWith(baseLang)) return supportedLang;
        }
        return 'en-US';
    }

    function getProductUrl(lang) {
        return `https://note2link.com/${lang}/vscode-sync-for-github`;
    }

    const currentLang = detectLanguage();
    const t = translations[currentLang];
    const productUrl = getProductUrl(currentLang);

    function createPromoBanner() {
        const banner = document.createElement('div');
        banner.id = 'vscode-sync-github-banner';
        banner.innerHTML = `
            <div style="
                position: fixed;
                top: 50px;
                right: 20px;
                width: 340px;
                background: rgba(0, 120, 212, 0.85);
                color: rgba(255, 255, 255, 0.95);
                padding: 24px;
                border-radius: 16px;
                box-shadow: 0 20px 40px rgba(0, 120, 212, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.08);
                z-index: 10000;
                font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
                backdrop-filter: blur(20px) saturate(180%);
                -webkit-backdrop-filter: blur(20px) saturate(180%);
                border: 1px solid rgba(255, 255, 255, 0.12);
                animation: slideInGlass 0.6s cubic-bezier(0.16, 1, 0.3, 1);
                overflow: hidden;
            ">
                <div style="
                    position: absolute;
                    top: 0;
                    left: 0;
                    right: 0;
                    height: 1px;
                    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
                "></div>
                <div style="display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px;">
                    <h3 style="
                        margin: 0; 
                        font-size: 17px; 
                        font-weight: 600; 
                        color: rgba(255, 255, 255, 0.95);
                        line-height: 1.3;
                        letter-spacing: -0.01em;
                    ">${t.title}</h3>
                    <button onclick="this.parentElement.parentElement.parentElement.remove()" style="
                        background: rgba(255, 255, 255, 0.08);
                        border: none;
                        color: rgba(255, 255, 255, 0.7);
                        font-size: 16px;
                        cursor: pointer;
                        padding: 0;
                        width: 28px;
                        height: 28px;
                        display: flex;
                        align-items: center;
                        justify-content: center;
                        border-radius: 8px;
                        transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
                        backdrop-filter: blur(10px);
                        border: 1px solid rgba(255, 255, 255, 0.1);
                    " onmouseover="
                        this.style.background='rgba(255, 255, 255, 0.15)'; 
                        this.style.color='rgba(255, 255, 255, 0.9)';
                        this.style.transform='scale(1.05)';
                    " onmouseout="
                        this.style.background='rgba(255, 255, 255, 0.08)'; 
                        this.style.color='rgba(255, 255, 255, 0.7)';
                        this.style.transform='scale(1)';
                    ">×</button>
                </div>
                <p style="
                    margin: 0 0 12px 0; 
                    font-size: 13px; 
                    color: rgba(255, 255, 255, 0.75); 
                    font-weight: 500;
                    letter-spacing: -0.005em;
                ">${t.subtitle}</p>
                <p style="
                    margin: 0 0 18px 0; 
                    font-size: 12px; 
                    color: rgba(255, 255, 255, 0.65); 
                    line-height: 1.5;
                    letter-spacing: -0.003em;
                ">${t.description}</p>
                <div style="margin-bottom: 20px;">
                    ${t.features.map(feature => `
                        <div style="
                            font-size: 11px; 
                            margin: 6px 0; 
                            color: rgba(255, 255, 255, 0.8);
                            padding: 4px 0;
                            border-bottom: 1px solid rgba(255, 255, 255, 0.06);
                        ">${feature}</div>
                    `).join('')}
                </div>
                <a href="${productUrl}" target="_blank" style="
                    display: inline-block;
                    background: rgba(16, 110, 190, 0.8);
                    color: rgba(255, 255, 255, 0.95);
                    text-decoration: none;
                    padding: 12px 20px;
                    border-radius: 10px;
                    font-weight: 600;
                    font-size: 13px;
                    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
                    border: 1px solid rgba(255, 255, 255, 0.15);
                    width: 100%;
                    text-align: center;
                    box-sizing: border-box;
                    backdrop-filter: blur(10px);
                    letter-spacing: -0.005em;
                    position: relative;
                    overflow: hidden;
                " onmouseover="
                    this.style.background='rgba(20, 130, 220, 0.9)'; 
                    this.style.transform='translateY(-2px)';
                    this.style.boxShadow='0 8px 25px rgba(0, 120, 212, 0.3)';
                    this.style.borderColor='rgba(255, 255, 255, 0.25)';
                " onmouseout="
                    this.style.background='rgba(16, 110, 190, 0.8)'; 
                    this.style.transform='translateY(0)';
                    this.style.boxShadow='none';
                    this.style.borderColor='rgba(255, 255, 255, 0.15)';
                ">${t.cta}</a>
                <div style="
                    text-align: center; 
                    margin-top: 16px; 
                    font-size: 10px; 
                    color: rgba(255, 255, 255, 0.5);
                    letter-spacing: 0.02em;
                ">${t.powered}</div>
            </div>
        `;

        const style = document.createElement('style');
        style.textContent = `
            @keyframes slideInGlass {
                from { transform: translateX(100%) scale(0.9); opacity: 0; backdrop-filter: blur(0px); }
                to { transform: translateX(0) scale(1); opacity: 1; backdrop-filter: blur(20px) saturate(180%); }
            }
            @keyframes slideOutGlass {
                from { transform: translateX(0) scale(1); opacity: 1; backdrop-filter: blur(20px) saturate(180%); }
                to { transform: translateX(100%) scale(0.9); opacity: 0; backdrop-filter: blur(0px); }
            }
        `;
        document.head.appendChild(style);
        return banner;
    }

    function showBanner() {
        if (document.getElementById('vscode-sync-github-banner')) return;
        if (document.readyState === 'loading') {
            document.addEventListener('DOMContentLoaded', showBanner);
            return;
        }
        const banner = createPromoBanner();
        document.body.appendChild(banner);
        setTimeout(() => {
            const existingBanner = document.getElementById('vscode-sync-github-banner');
            if (existingBanner) {
                existingBanner.style.animation = 'slideOutGlass 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards';
                setTimeout(() => existingBanner.remove(), 600);
            }
        }, 15000);
    }

    showBanner();
    setInterval(() => showBanner(), 5 * 60 * 1000);
    let lastUrl = location.href;
    new MutationObserver(() => {
        const url = location.href;
        if (url !== lastUrl) {
            lastUrl = url;
            setTimeout(showBanner, 2000);
        }
    }).observe(document, { subtree: true, childList: true });

})();