Skip to content

Instantly share code, notes, and snippets.

@g-rohit
Last active July 22, 2025 09:21
Show Gist options
  • Save g-rohit/ffc0184d628946d18bf12ecdf832955a to your computer and use it in GitHub Desktop.
Save g-rohit/ffc0184d628946d18bf12ecdf832955a to your computer and use it in GitHub Desktop.
Get Google photo album names
// Run this in the browser console while logged into Google Photos Albums page
(function() {
let albumNames = [];
const links = document.getElementsByTagName('A');
for (let i = 0; i < links.length; i++) {
const link = links[i];
// Google Photos albums usually show count like '123 items' in their text; skip those links
if (/\b\d+ items\b/.test(link.innerText)) {
const divs = link.getElementsByTagName('DIV');
for (let j = 0; j < divs.length; j++) {
const div = divs[j];
const text = div.innerText;
if (text !== "" && div.childElementCount === 0 && !/\b\d+ items\b/.test(text)) {
albumNames.push(text);
break;
}
}
}
}
// Print all album names
console.log(albumNames);
// Or to see as a single string
console.log(albumNames.join('\n'));
})();
// ----- if you want the albums with the links as well
(function() {
let albums = [];
const links = document.getElementsByTagName('A');
for (let i = 0; i < links.length; i++) {
const link = links[i];
if (/\b\d+ items\b/.test(link.innerText)) {
const divs = link.getElementsByTagName('DIV');
for (let j = 0; j < divs.length; j++) {
const div = divs[j];
const text = div.innerText;
if (text !== "" && div.childElementCount === 0 && !/\b\d+ items\b/.test(text)) {
albums.push({ name: text, url: link.href });
break;
}
}
}
}
console.table(albums); // See as a table
})();
@g-rohit
Copy link
Author

g-rohit commented Jul 20, 2025

  1. One needs to be on the Google photos album page :
    Example - https://photos.google.com/u/0/albums
  2. Open the console using F12 -> Console Tab and run the above Code.

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