Skip to content

Instantly share code, notes, and snippets.

@maxxcrawford
Created March 3, 2021 04:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxxcrawford/9557cf672186698f22aed5748d2d2248 to your computer and use it in GitHub Desktop.
Save maxxcrawford/9557cf672186698f22aed5748d2d2248 to your computer and use it in GitHub Desktop.
Script used to select all videos from a Google Photos album
// Run this script in your DevTools console
// Calculate how many times you'll need to scroll down the page.
var pageHeight = window.innerHeight;
var windowEl = document.querySelector(".Ac8dXc");
var loopCount = Math.ceil(windowEl.offsetHeight / pageHeight)
// Running array of images (based on what is visible on the scren)
var videos = document.querySelectorAll("div[aria-label*='Video']");
// Click the video thumbnail, only if it is not already clicked
var clickCheck = function(el) {
var checked = el.getAttribute("aria-checked");
if (checked === "false") {
el.click();
}
}
var loopFunc = function(i) {
// Dynamically buffer the loop function
var timeOutTime = (i*500)+500;
setTimeout(() => {
videos = document.querySelectorAll("div[aria-label*='Video']");
videos.forEach(element => clickCheck(element));
windowEl.scrollBy(0, pageHeight);
}, timeOutTime);
}
// Run the command!
for (let i = 0; i < loopCount; i++) {
console.log("loopFunc: ", i);
loopFunc(i);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment