Last active
December 11, 2025 16:35
-
-
Save jhyland87/abd4ad3d1dbb6ba489afe7a3fcec0263 to your computer and use it in GitHub Desktop.
Select all photobucket images
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
| const selectMode = () => { | |
| const selectModeButton = document.querySelector('[data-test="select-mode"]'); | |
| if ( ! selectModeButton ) | |
| throw new Error('No select mode button found') | |
| if ( selectModeButton.textContent === 'Cancel' ) { | |
| console.log('Already in select model') | |
| return; | |
| } | |
| selectModeButton.click(); | |
| } | |
| // Get the image selection buttons | |
| const getImageSelectionButtons = () => Array.from(document.querySelectorAll('[data-testid="CheckIcon"]')).map(e => e.parentElement) | |
| // Get the unselected images based on the opacity of the checkbox thingy. | |
| const getUnselectedImages = () => getImageSelectionButtons().filter(e => !+e.parentElement.querySelector('div').style.opacity) | |
| const getSelectedImages = () => getImageSelectionButtons().filter(e => +e.parentElement.querySelector('div').style.opacity) | |
| const selectUnselectedImages = () => { | |
| const unselectedImages = getUnselectedImages(); | |
| if ( ! unselectedImages?.length ) return; | |
| unselectedImages.forEach(e => e.click()) | |
| return unselectedImages.length | |
| } | |
| // Check if the gallery is at the bottom of the page | |
| const isGalleryAtBottom = () => { | |
| const galleryElement = document.getElementById("gallery"); | |
| const top = galleryElement.getBoundingClientRect().top; | |
| const bottom = galleryElement.getBoundingClientRect().bottom; | |
| return top <= window.innerHeight && bottom >= 0; | |
| } | |
| const scrollToGalleryBottom = () => { | |
| const galleryElement = document.getElementById("gallery"); | |
| galleryElement.scrollTo(0, galleryElement.scrollHeight-100) | |
| } | |
| const delay = ms => new Promise(resolve => setTimeout(resolve, ms)) | |
| const selectAllImages = async () => { | |
| selectMode(); | |
| let totalSelected = 0; | |
| while(true){ | |
| const selectUnselected = selectUnselectedImages(); | |
| totalSelected += selectUnselected; | |
| await delay(500) | |
| if ( ! selectUnselected ){ | |
| console.log('No unselected images found') | |
| break; | |
| } | |
| console.log(`Selected ${selectUnselected} unselected images`); | |
| scrollToGalleryBottom(); | |
| await delay(1000) | |
| } | |
| console.log(`Total selected images: ${totalSelected}. You may now export the selected images`); | |
| } | |
| selectAllImages(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment