Greasy Fork is available in English.

images predownload

predownload the images in web

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         images predownload
// @license      MIT
// @namespace    https://github.com/xgame-0/tamper-monkey-script
// @version      2026-03-31
// @description  predownload the images in web
// @author       xgame-0
// @match        *://hmjidi.com/*
// @include      /^https?:\/\/aman\d+\.(com|org)\//
// @include      /^https?:\/\/xman\d+\.com\//
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    const CONFIGS = [
        {
            regExp: /^(?:aman\d+\.(?:com|org)|xman\d+\.com)$/,
            attr: 'data-original',
        },
        {
            host: ['hmjidi.com'],
            attr: 'data-src',
        }
    ];

    function checkConfigHost(cfgHost) {
        const host = window.location.host;

        if (!Array.isArray(cfgHost)) {
            return !!cfgHost && host.includes(cfgHost);
        }

        return cfgHost.some(item => checkConfigHost(item));
    }

    function checkConfigRegExp(re) {
        const host = window.location.host;

        if (!Array.isArray(re)) {
            return !!re && re.test(host);
        }

        return re.some(item => checkConfigRegExp(item));
    }

    function getConfig() {
        return CONFIGS.filter(cfg => {
            if (cfg.host) return checkConfigHost(cfg.host);
            if (cfg.regExp) return checkConfigRegExp(cfg.regExp);
            return false;
        });
    }

    function predownloadImage(attrName) {
        const images = document.querySelectorAll('img');

        images.forEach((e) => {
            const attrValue = e.getAttribute(attrName);
            if (!attrValue) return;

            const img = new Image();
            img.src = attrValue;
        });
    }

    function main(ev) {
        console.log('event:', ev);
        const cfgs = getConfig();
        console.log('host:', window.location.host, 'cfgs:', cfgs);

        cfgs.forEach(cfg => {
            predownloadImage(cfg.attr);
        });
    }

    if (['complete', 'interactive'].includes(document.readyState)) {
        main();
    } else {
        window.addEventListener('DOMContentLoaded', main, { once: true });
        window.addEventListener('load', main, { once: true });
    }
})();