Skip to content

Instantly share code, notes, and snippets.

@papaemman
Last active August 20, 2025 09:45
Show Gist options
  • Save papaemman/956d5436651f2a408991ea89dcf3e7c8 to your computer and use it in GitHub Desktop.
Save papaemman/956d5436651f2a408991ea89dcf3e7c8 to your computer and use it in GitHub Desktop.
How to Download All Files from a Fotoshare.co Album Using Browser Scripts**

Fotoshare.co, does not always offer a built-in option to download all images or videos from an album at once. However, using the following script, you can automate the download process directly from your browser. This script will allow you to download all images and videos from a specific album on Fotoshare.co without the need for manual downloading.

Steps to Use the Script:

  1. Open the Fotoshare Album:

Navigate to the album on Fotoshare.co that you want to download. Make sure the page is fully loaded and the sessionImages object containing the image/video data is accessible in the browser's JavaScript environment.

  1. Open the Browser Developer Tools:
  • In Chrome, press Ctrl + Shift + I (Windows) or Cmd + Option + I (Mac) to open Developer Tools.
  • In Firefox, press Ctrl + Shift + I (Windows) or Cmd + Option + I (Mac).
  1. Go to the Console Tab:
    Switch to the Console tab in Developer Tools, where you can execute JavaScript.

  2. Paste the Script:

Copy the provided JavaScript code (see below) and paste it into the console. Make sure that the sessionImages object is already available on the page (this typically depends on how the page is structured or loaded).

  1. Run the Script:

After pasting the script, press Enter to run it. The script will automatically download all the images and videos from the session, and you’ll see each file being downloaded.

  1. Check the Downloads Folder:

Once the script completes, check your browser’s default download folder. All files should be automatically saved without prompting for each file.

Script Explanation and Why it Works

  • Session Structure:
    Fotoshare.co stores albums and images in a nested structure. For example, sessionImages might look like:

    {
        "1xiXKdN8R9": {
            "377x5x1": { ... },
            "2r7g9jm": { ... }
        },
        "1~8IvladYd": {
            "53w35ed": { ... },
            "2ge1vvp": { ... }
        },
        ...
    }

    Each session contains multiple images or videos, with each file having a unique img URL and associated file type (e.g., mp4, jpg).

  • Automatic File Detection:

The script checks each image entry in the session and detects the correct file extension from the img URL or fileType property. If fileType is missing, it tries to infer it from the URL.

  • File Naming:

Each file is named using a combination of the session ID and the unique image hash to avoid name conflicts across sessions. For example, 1xiXKdN8R9_377x5x1.mp4 ensures that filenames remain unique.

  • No Prompts for Download Locations:

If the browser’s settings are configured to not ask where to save each file, the files will be automatically downloaded into the default download folder without further user interaction.

  • Cross-Session Download:
    The script handles multiple sessions by iterating through all the session IDs and downloading the corresponding files (images and videos) from each session.

Key Benefits:

  • Efficiency: Download all files from a Fotoshare.co album in one go.
  • Automation: No need to manually download each file or specify locations.
  • Customizable: The script is designed to work with any Fotoshare album as long as the sessionImages object is available.
  • Browser-Friendly: Runs directly in the browser, no need for external tools or extensions.

Limitations:

  • Browser Settings: Ensure that your browser’s download settings are configured to avoid prompts for each file. If this is not set up, the script might still ask where to save each file.
  • Availability of sessionImages: This script assumes that the sessionImages object is accessible and contains the correct data (URLs, hashes, and file types) for the images and videos in the album.
async function downloadFile(url, filename) {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`Failed to fetch ${url}`);
}
const blob = await response.blob();
const link = document.createElement("a");
link.href = URL.createObjectURL(blob);
link.download = filename;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
async function downloadAllImages(sessionImages) {
for (const sessionId in sessionImages) {
if (sessionImages.hasOwnProperty(sessionId)) {
const images = sessionImages[sessionId];
for (const imageId in images) {
if (images.hasOwnProperty(imageId)) {
const item = images[imageId];
const fileUrl = item.img;
// Detect file type if missing
let fileType = item.fileType;
if (!fileType && fileUrl) {
// Try extracting file type from URL
const match = fileUrl.match(/\.(mp4|jpg|jpeg|png|gif|webp)$/i);
fileType = match ? match[1] : "unknown";
}
const fileName = `${sessionId}_${item.hash}.${fileType}`;
if (fileUrl) {
console.log(`Downloading: ${fileName}`);
await downloadFile(fileUrl, fileName);
} else {
console.warn(`Missing file URL for item: ${imageId} in session: ${sessionId}`);
}
}
}
}
}
console.log("All files downloaded.");
}
// Example sessionImages structure
const sessionImages = {
"1xiXKdN8R9": {
"377x5x1": {
"hash": "377x5x1",
"img": "https://cdn-bz.fotoshare.co/b/1c7ac/-O4z2rB4H6cRAgXNzGei/20240824_224954741.mp4",
"fileType": "mp4"
},
"2r7g9jm": {
"hash": "2r7g9jm",
"img": "https://cdn-bz.fotoshare.co/b/1c7ac/-O4z2rB4H6cRAgXNzGei/20240824_224954741.jpg",
"fileType": "jpg"
}
},
"1~8IvladYd": {
"53w35ed": {
"hash": "53w35ed",
"img": "https://cdn-bz.fotoshare.co/b/1c7ac/-O4z2rB4H6cRAgXNzGei/some_image.png",
"fileType": "png"
},
"2ge1vvp": {
"hash": "2ge1vvp",
"img": "https://cdn-bz.fotoshare.co/b/1c7ac/-O4z2rB4H6cRAgXNzGei/another_image.jpg",
"fileType": "jpg"
}
}
};
// Call the function to download all images/videos
downloadAllImages(sessionImages);
@HandyHat
Copy link

This is extremely helpful - thank you!
For anyone else looking at this, when copy pasting the code into the console you need to remove the example sessionImages object that is included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment