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