Bunkrr DL Button

Add a direct download button below each thumbnails

目前為 2023-11-01 提交的版本,檢視 最新版本

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


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

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

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

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

  await Promise.all(
    links.map(async (link, i) => {
      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");

      const media = medias[i];

      media.style.border = "none";
      media.style.padding = "0";
      const mediaChildren = media.querySelectorAll(":scope > *");
      mediaChildren[mediaChildren.length - 1].style.bottom = "0";

      const newMediaBox = document.createElement("div");
      newMediaBox.style.position = "relative";
      newMediaBox.style.padding = "0.625rem";
      newMediaBox.style.paddingBottom = "0";
      newMediaBox.style.border = "solid #ffd369 2px";
      newMediaBox.style.borderBottom = "none";

      newMediaBox.append(...mediaChildren);

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

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

        window.open(ddlLink);
      });

      media.style.display = "flex";
      media.style.flexDirection = "column";

      media.append(newMediaBox, dlBox);
    }));
})();



QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址