Downloader

try

当前为 2024-01-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Downloader
  3. // @namespace http://yu.net/
  4. // @version 2024-01-19
  5. // @description try
  6. // @author Yu
  7. // @match https://bunkrr.ru/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=bunkrr.ru
  9. // @grant GM_download
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. function createProgressElement() {
  14. const container = document.createElement("div")
  15. container.classList.add("fixed", "bottom-0", "left-0", "w-full", "bg-gray-200", "rounded-full", "h-2.5", "dark:bg-gray-700")
  16.  
  17. const progress = document.createElement("div")
  18. progress.classList.add("progress", "bg-blue-600", "h-2.5", "rounded-full")
  19.  
  20. container.append(progress)
  21.  
  22. return container;
  23. }
  24.  
  25. function createDownloadElement() {
  26. const button = document.createElement("button")
  27. button.style.background = "#ffd369";
  28. button.style.color = "#272727"
  29. button.style.fontWeight = "bold";
  30. button.classList.add("block", "mx-auto", "py-2", "px-4", "rounded");
  31. button.innerText = "Download All";
  32.  
  33. return button
  34. }
  35.  
  36. function handleDownloadAllImages() {
  37. const elements = document.querySelectorAll(".grid-images_box a");
  38. const images = []
  39. elements.forEach(item => images.push(`https://i-taquito.bunkr.ru/${item.href.replace("https://bunkrr.ru/i/", "")}`))
  40. function getFilename(path) {
  41. path = path.split("/")
  42. return path[path.length -1]
  43. }
  44.  
  45. for(const img of images) {
  46. const title = getFilename(img)
  47. GM_download(img, title)
  48. break
  49. }
  50. }
  51.  
  52. (function() {
  53. 'use strict';
  54.  
  55. const button = createDownloadElement();
  56. button.onclick = handleDownloadAllImages;
  57.  
  58. const progress = createProgressElement();
  59. document.querySelector("section").append(button, progress);
  60. document.body.append(progress);
  61. })();