Created
March 3, 2021 04:15
-
-
Save maxxcrawford/9557cf672186698f22aed5748d2d2248 to your computer and use it in GitHub Desktop.
Script used to select all videos from a Google Photos album
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 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