Bulk Export Dropbox Image URLs to Clipboard (2023)

Extracts image URLs from a Dropbox page and copies them to the clipboard when a button is clicked.

  1. // ==UserScript==
  2. // @name Bulk Export Dropbox Image URLs to Clipboard (2023)
  3. // @version 3.2
  4. // @description Extracts image URLs from a Dropbox page and copies them to the clipboard when a button is clicked.
  5. // @author sharmanhall
  6. // @supportURL https://github.com/tyhallcsu/dropbox-image-url-extractor/issues/new
  7. // @namespace https://github.com/tyhallcsu/dropbox-image-url-extractor
  8. // @homepageURL https://github.com/tyhallcsu/dropbox-image-url-extractor
  9. // @license MIT
  10. // @connect gf.qytechs.cn
  11. // @connect sleazyfork.org
  12. // @connect github.com
  13. // @connect openuserjs.org
  14. // @match https://www.dropbox.com/*
  15. // @grant GM_setClipboard
  16. // @grant GM_log
  17. // @compatible chrome
  18. // @compatible firefox
  19. // @compatible edge
  20. // @compatible opera
  21. // @compatible safari
  22. // @run-at document-idle
  23. // @icon https://cfl.dropboxstatic.com/static/metaserver/static/images/favicon-vfl8lUR9B.ico
  24. // ==/UserScript==
  25.  
  26. (function() {
  27. 'use strict';
  28.  
  29. const SECONDS_TO_WAIT_FOR_SCROLL = 1; // adjust as needed
  30. const DOWNLOAD_URL_REPLACEMENT = '?raw=1';
  31.  
  32. // function to get all image link elements
  33. function getImageLinks() {
  34. const imageLinks = document.querySelectorAll('a.dig-Link.sl-link--file[href*="dl=0"]');
  35. return Array.from(imageLinks).map(link => link.getAttribute('href').replace(/\?dl=0$/, DOWNLOAD_URL_REPLACEMENT));
  36. }
  37.  
  38. // function to scroll to the bottom of the page and wait for new images to load
  39. async function waitForImagesToLoad() {
  40. window.scrollTo(0, document.body.scrollHeight);
  41. await new Promise(resolve => setTimeout(resolve, SECONDS_TO_WAIT_FOR_SCROLL * 1000));
  42. }
  43.  
  44. // create an array to hold the image URLs
  45. let imageUrls = [];
  46.  
  47. // add a button to the page that will copy the image URLs to the clipboard when clicked
  48. const copyButton = document.createElement('button');
  49. copyButton.classList.add('dig-Button', 'dig-Button--primary', 'dig-Button--standard', 'copy-urls-button');
  50. copyButton.textContent = 'Copy all URLs';
  51. copyButton.style.position = 'fixed';
  52. copyButton.style.bottom = '20px';
  53. copyButton.style.right = '20px';
  54. copyButton.style.zIndex = '9999';
  55. document.body.appendChild(copyButton);
  56.  
  57. // add a click event listener to the button
  58. copyButton.addEventListener('click', async function() {
  59. let finished = false;
  60. let numUrls = 0;
  61. while (!finished) {
  62. // scroll to the bottom of the page and wait for new images to load
  63. await waitForImagesToLoad();
  64.  
  65. // get the newly loaded image URLs
  66. const newImageUrls = getImageLinks().filter(url => !imageUrls.includes(url));
  67. imageUrls.push(...newImageUrls);
  68.  
  69. // check if all images have been loaded
  70. finished = newImageUrls.length === 0;
  71.  
  72. numUrls += newImageUrls.length;
  73. }
  74.  
  75. // join the image URLs into a string separated by newlines
  76. const imageUrlString = imageUrls.join('\n');
  77.  
  78. // copy the image URL string to the clipboard
  79. GM_setClipboard(imageUrlString, 'text');
  80.  
  81. // disable the button and change the text to indicate that the URLs have been copied
  82. copyButton.disabled = true;
  83. copyButton.textContent = `${numUrls} URL(s) copied to clipboard`;
  84.  
  85. // enable the button again after 3 seconds
  86. setTimeout(function() {
  87. imageUrls = [];
  88. copyButton.disabled = false;
  89. copyButton.textContent = 'Copy all URLs';
  90. }, 3000);
  91. });
  92. })();

QingJ © 2025

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