JPG Cat album Download

try

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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)
})();