Replace preview with i

Replace preview with i in Reddit image URLs

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         Replace preview with i
// @namespace    https://i.redd.it
// @version      1.0
// @description  Replace preview with i in Reddit image URLs
// @match        *://*/*
// @run-at       document-idle
// ==/UserScript==

(function() {
    'use strict';
    // Define a function to replace image URLs
    function replaceImageURLs() {
        // Get all images on the page
        var images = document.getElementsByTagName("img");
        // Loop through each image
        for (var i = 0; i < images.length; i++) {
            // Get the current src value
            var src = images[i].src;
            // Check if it contains preview.redd.it
            if (src.includes("preview.redd.it")) {
                // Replace preview with i
                var newSrc = src.replace("preview", "i");
                // Set the new src value
                images[i].src = newSrc;
            }
        }
    }
    // Create a mutation observer instance
    var observer = new MutationObserver(replaceImageURLs);
    // Define the observer options: observe all child nodes and attributes of the body element
    var options = {childList: true, subtree: true, attributes: true};
    // Start observing the body element for changes
    observer.observe(document.body, options);
})();