Last active
July 22, 2025 09:21
-
-
Save g-rohit/ffc0184d628946d18bf12ecdf832955a to your computer and use it in GitHub Desktop.
Get Google photo album names
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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 | |
| })(); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example - https://photos.google.com/u/0/albums