-
Go to your sketches page on p5.js Web Editor (such as this)
-
Go to your browser's JavaScript console, copy and paste the script below:
let sketchLinks = document.querySelectorAll('.sketches-table__row a');
let textContent = '';
sketchLinks.forEach(link => textContent += link.innerHTML + ',' + link.href + '\n');
// Create a Blob containing the text content
let blob = new Blob([textContent], { type: "text/plain" });
// Create a temporary anchor element
let a = document.createElement("a");
a.style.display = "none";
// Set the download attribute and file name
a.href = window.URL.createObjectURL(blob);
a.download = "filenames_and_p5js_sketch_urls.txt";
// Append the anchor to the body and click it
document.body.appendChild(a);
a.click();
// Clean up
window.URL.revokeObjectURL(a.href);
document.body.removeChild(a);-
Press Enter to run the script in order to extract and download filenames_and_p5js_sketch_urls.txt (you may need to click somewhere on the sketches page before running the script if the download fails or the downloaded file is blank)
-
Save batch-download.sh in the same folder as filenames_and_p5js_sketch_urls.txt
-
In Terminal, navigate to the same folder and run the batch-download.sh with the command below to start downloading:
bash batch-download.sh-
filenames_and_p5js_sketch_urls.txt is formatted as filename,url in each line, you can delete the lines that you do not wish to download before running batch-download.sh
-
Todos:
- Apply compression to the zip files
These scripts are intended for batch downloading one's own sketches, as p5.js Web Editor does not currently offer this feature. Make sure to obtain appropriate permissions from the author before downloading sketches that are not your own.
Made with help from ChatGPT