Created
January 31, 2024 00:29
-
-
Save volkankaban/2abfa05b57b9da9d56ad0ebc66699e1f to your computer and use it in GitHub Desktop.
Google Photos Manager (Sync, Hash & Remove Duplicates)
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
// Define the checkbox class | |
var checkboxClass = '.ckGgle'; | |
// Get all elements with the specified checkbox class | |
var checkboxes = document.querySelectorAll(checkboxClass); | |
// Function to check the checkbox if it's currently unchecked | |
function checkIfUnchecked(checkbox) { | |
var isChecked = checkbox.getAttribute('aria-checked') === 'true'; | |
// Check the checkbox only if it's currently unchecked | |
if (!isChecked) { | |
checkbox.click(); | |
} | |
} | |
// Call the function for each checkbox | |
checkboxes.forEach(function(checkbox) { | |
checkIfUnchecked(checkbox); | |
}); |
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
function removeDuplicatePhotos(photos) { | |
// Assume photos is an array of photo objects with properties including fileHash. | |
// Create a Map to store unique photos based on fileHash | |
const uniquePhotos = new Map(); | |
// Iterate through the photos | |
photos.forEach(photo => { | |
// Check if the fileHash is not already in the Map | |
if (!uniquePhotos.has(photo.fileHash)) { | |
// Add the photo to the Map if it's unique | |
uniquePhotos.set(photo.fileHash, photo); | |
} | |
}); | |
// Convert the Map back to an array of unique photos | |
const uniquePhotosArray = Array.from(uniquePhotos.values()); | |
// Now uniquePhotosArray contains photos without duplicates | |
return uniquePhotosArray; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment