Temp fix bato

Fix the current broken page on bato.to

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Temp fix bato
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Fix the current broken page on bato.to
// @author       entityJY
// @license      MIT
// @match        https://bato.to/title/*
// @match        https://mto.to/title/*
// @icon        https://bato.to/amsta/img/btoto/logo-batoto.png?v0
// @grant        none
// ==/UserScript==
 
(function() {
    'use strict';
 
    var images = document.getElementsByTagName('img');
 
    let retries = 11;
 
    let integer = 0;
 
    const regex = new RegExp("^https:\/\/(s|d|k)\\d\\d");
 
    var timeoutId = setTimeout(_ => {
 
        const intervalID = setInterval(_ => {
            for(var i = 0; i < images.length; i++) {
                if (images[i].naturalWidth === 0) {
                    if(images[i].src.match(regex)){
                        images[i].src = images[i].src.replace(regex, images[i].src.match(regex)[0].substring(0, images[i].src.match(regex)[0].length - 2) + String(integer).padStart(2, '0'));//We try all combination from 00 to 10
                    }
                }
            }
            integer++;
            retries--;
            if(retries == 0){
                images = null;
                clearInterval(intervalID);
            }
        }, 500);//Attempt evey .5 seconds
 
    }, 500);//.5 second dealy
 
 
})();