V2EX Imgur Proxy

Replace Imgur links with DuckDuckGo proxy on V2EX

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         V2EX Imgur Proxy
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Replace Imgur links with DuckDuckGo proxy on V2EX
// @author       You
// @match        https://www.v2ex.com/t/*
// @icon         https://www.google.com/s2/favicons?bb=1&domain=v2ex.com
// @grant        none
// @license      MIT License
// ==/UserScript==

(function() {
    'use strict';

    const proxyPrefix = "https://external-content.duckduckgo.com/iu/?u=";

    function replaceImgur() {
        // 1. Handle actual <img> tags
        const images = document.querySelectorAll('img[src*="i.imgur.com"]');
        images.forEach(img => {
            if (!img.src.includes(proxyPrefix)) {
                img.src = proxyPrefix + img.src;
            }
        });

        // 2. Handle <a> links
        const links = document.querySelectorAll('a[href*="i.imgur.com"]');
        links.forEach(link => {
            if (!link.href.includes(proxyPrefix)) {
                link.href = proxyPrefix + link.href;
            }
        });

        // 3. Handle text-only links in posts (V2EX often auto-links these)
        // This looks for elements containing the specific string
        const walker = document.createTreeWalker(document.getElementById('Wrapper'), NodeFilter.SHOW_TEXT, null, false);
        let node;
        while(node = walker.nextNode()) {
            if (node.nodeValue.includes('https://i.imgur.com/') && !node.parentElement.closest('a')) {
                 // If there's raw text not inside a link, this part is harder to replace without
                 // breaking the DOM, but V2EX usually converts these to <a> tags anyway.
            }
        }
    }

    // Run immediately
    replaceImgur();

    // Also run when the content changes (for AJAX loaded replies or previews)
    const observer = new MutationObserver(replaceImgur);
    observer.observe(document.body, {
        childList: true,
        subtree: true
    });
})();