Imgur UK Unblocker

Redirects Imgur images through a proxy to bypass the UK regional block.

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

You will need to install an extension such as Tampermonkey to install this script.

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Imgur UK Unblocker
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Redirects Imgur images through a proxy to bypass the UK regional block.
// @author       GallantSirKnight
// @match        *://*/*
// @grant        none
// @run-at       document-start
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

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

    function fixImgur(element) {
        // Fix standard <img> tags
        if (element.tagName === 'IMG' && element.src.includes('imgur.com')) {
            if (!element.src.includes(PROXY_URL)) {
                element.src = PROXY_URL + encodeURIComponent(element.src);
            }
        }
        // Fix background images (common in forums/galleries)
        if (element.style && element.style.backgroundImage.includes('imgur.com')) {
            let urlMatch = element.style.backgroundImage.match(/url\(["']?(.*?)["']?\)/);
            if (urlMatch && !urlMatch[1].includes(PROXY_URL)) {
                element.style.backgroundImage = `url("${PROXY_URL}${encodeURIComponent(urlMatch[1])}")`;
            }
        }
    }

    // Observe the page for dynamically loaded images (like on Reddit/Twitter)
    const observer = new MutationObserver((mutations) => {
        mutations.forEach((mutation) => {
            mutation.addedNodes.forEach((node) => {
                if (node.nodeType === 1) { // ELEMENT_NODE
                    if (node.tagName === 'IMG') fixImgur(node);
                    node.querySelectorAll('img, [style*="imgur.com"]').forEach(fixImgur);
                }
            });
        });
    });

    // Run on existing elements
    document.querySelectorAll('img, [style*="imgur.com"]').forEach(fixImgur);

    // Start observing
    observer.observe(document.documentElement, {
        childList: true,
        subtree: true
    });
})();