Bunkrr DL Button

Add a download button below each thumbnails

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Bunkrr DL Button
// @version      1
// @description  Add a download button below each thumbnails
// @match        https://bunkrr.su/a/*
// @namespace    bunkrr
// @license      MIT
// ==/UserScript==

(async () => {
  "use strict";
  const mediaLinks = Array.from(
    document.querySelectorAll(".grid-images_box-link")
  );

  const links = mediaLinks.map((mediaLink) => {
    const relativeLink = mediaLink.getAttribute("href");

    return window.location.origin + relativeLink;
  });

  const ddlLinks = await Promise.all(
    links.map(async (link) => {
      const response = await fetch(link);
      const html = await response.text();

      const parser = new DOMParser();
      const doc = parser.parseFromString(html, "text/html");

      const ddlLink = doc.querySelector("a[href$='.mp4']").getAttribute("href");

      return ddlLink;
    })
  );

  const grid = document.querySelector(".grid-images");
  const medias = document.querySelectorAll(".grid-images > *");

  medias.forEach((media, i) => {
    const newBox = document.createElement("div");
    newBox.style.display = "flex";
    newBox.style.flexDirection = "column";

    const dlBox = document.createElement("button");
    dlBox.textContent = "Download";
    dlBox.style.border = "solid #ffd369 2px";
    dlBox.style.borderRadius = "0px 0px 20px 20px";

    dlBox.addEventListener("click", (e) => {
      e.stopPropagation();

      window.open(ddlLinks[i]);
    });

    media.style.borderBottom = "none";
    media.style.borderBottomLeftRadius = "0px";
    media.style.borderBottomRightRadius = "0px";
    newBox.appendChild(media);
    newBox.appendChild(dlBox);
    grid.appendChild(newBox);
  });
})();