JPG Cat album Download

try

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         JPG Cat album Download
// @namespace    http://yu.net/
// @version      2024-01-16
// @description  try
// @author       Yu
// @match        https://jpg4.su/a/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=jpg4.su
// @grant        GM_openInTab
// @grant        GM_download
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    function handleClick(e) {
        e.preventDefault();
        const images = document.querySelectorAll(".pad-content-listing .list-item img")
        for(const img of images) {
            const url = img.src.replace(".md", "")
            let filename = url.pathname.split("/");
            filename = filename[filename.length - 1]
            filename = filename.replace(".md", "")
            GM_download(url, filename)
            // GM_openInTab(url)
        }
    }

    function handleCopyLink(e) {
        e.preventDefault();
        const images = document.querySelectorAll(".pad-content-listing .list-item img")
        let copy = ""
        for(const img of images) {
            const url = img.src.replace(".md", "")
            copy += `${url}\n`;
        }

        navigator.clipboard.writeText(copy);
    }

    const list = document.createElement("li")
    const a = document.createElement("a")
    a.innerText = "Download"
    a.onclick = handleClick

    const list2 = document.createElement("li")
    const a2 = document.createElement("a")
    a2.innerText = "Copy All Link"
    a2.onclick = handleCopyLink

    list.append(a)
    list2.append(a2)

    document.querySelector(".content-tabs").append(list, list2)
})();