Downloader

try

目前為 2024-01-26 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Downloader
// @namespace    http://yu.net/
// @version      2024-01-22
// @description  try 
// @author       Yu
// @match        https://bunkrr.ru/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=bunkrr.ru
// @require      https://cdn.jsdelivr.net/npm/[email protected]/dist/js-file-downloader.min.js
// @require      https://update.greasyfork.org/scripts/485684/1317487/Downloader%20JS%20File.js
// @grant        GM_download
// @license      MIT
// ==/UserScript==

function createProgressElement() {
    const container = document.createElement("div")
    container.classList.add("fixed", "bottom-0", "left-0", "w-full", "bg-gray-200", "rounded-full", "h-2.5", "dark:bg-gray-700")

    const progress = document.createElement("div")
    progress.classList.add("progress", "bg-blue-600", "h-2.5", "rounded-full")

    container.append(progress)

    return container;
}

function createDownloadElement() {
    const button = document.createElement("button")
    button.style.background = "#ffd369";
    button.style.color = "#272727"
    button.style.fontWeight = "bold";
    button.classList.add("block", "mx-auto", "py-2", "px-4", "rounded");
    button.innerText = "Download All";

    return button
}

function handleDownloadAllImages() {
    const elements = document.querySelectorAll(".grid-images_box a");
    const images = []
    elements.forEach(item => images.push(`https://i-taquito.bunkr.ru/${item.href.replace("https://bunkrr.ru/i/", "")}`))
    function getFilename(path) {
        path = path.split("/")
        path = path[path.length -1]
        path = path.split(".")
        delete path[path.length -1]
        return path.join(".")
    }
    
    const downloader = new Downloader();

    for(const img of images) {
        download.add_url(img)
    }
    
    download.start()
}

(function() {
    'use strict';

    const button = createDownloadElement();
    button.onclick = handleDownloadAllImages;

    const progress = createProgressElement();
    document.querySelector("section").append(button, progress);
    document.body.append(progress);
})();