Florr.io Image Gatherer

Gather all images from florr.io and download as a ZIP file

  1. // ==UserScript==
  2. // @name Florr.io Image Gatherer
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description Gather all images from florr.io and download as a ZIP file
  6. // @author Your Name
  7. // @match *://florr.io/*
  8. // @grant none
  9. // @require https://cdnjs.cloudflare.com/ajax/libs/jszip/3.6.0/jszip.min.js
  10. // @require https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.5/FileSaver.min.js
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. const corsProxy = 'https://cors-anywhere.herokuapp.com/';
  17.  
  18. // Function to get base64 from image URL
  19. async function toDataURL(url) {
  20. try {
  21. const response = await fetch(corsProxy + url);
  22. const blob = await response.blob();
  23. return new Promise((resolve, reject) => {
  24. const reader = new FileReader();
  25. reader.onloadend = () => resolve(reader.result);
  26. reader.onerror = reject;
  27. reader.readAsDataURL(blob);
  28. });
  29. } catch (error) {
  30. console.error('Failed to fetch image:', error);
  31. }
  32. }
  33.  
  34. // Add the gather images button
  35. const gatherButton = document.createElement('button');
  36. gatherButton.innerHTML = 'Gather Images';
  37. gatherButton.style.position = 'fixed';
  38. gatherButton.style.top = '50%';
  39. gatherButton.style.left = '50%';
  40. gatherButton.style.transform = 'translate(-50%, -50%)';
  41. gatherButton.style.zIndex = '9999';
  42. gatherButton.style.border = '2px solid black';
  43. gatherButton.style.backgroundColor = 'white';
  44. gatherButton.style.color = 'black';
  45. gatherButton.style.padding = '10px';
  46. gatherButton.style.cursor = 'pointer';
  47. document.body.appendChild(gatherButton);
  48.  
  49. // Add click event listener to the button
  50. gatherButton.addEventListener('click', async () => {
  51. const zip = new JSZip();
  52. const images = document.querySelectorAll('img');
  53. for (let i = 0; i < images.length; i++) {
  54. const img = images[i];
  55. const dataUrl = await toDataURL(img.src);
  56. if (dataUrl) {
  57. const base64Data = dataUrl.split(',')[1];
  58. zip.file(`image${i}.png`, base64Data, {base64: true});
  59. }
  60. }
  61.  
  62. zip.generateAsync({type:"blob"})
  63. .then(function(content) {
  64. saveAs(content, "images.zip");
  65. });
  66. });
  67. })();