Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save daithinh/cb7277866fc139f833ed98cbe7c0818a to your computer and use it in GitHub Desktop.
Save daithinh/cb7277866fc139f833ed98cbe7c0818a to your computer and use it in GitHub Desktop.
Hướng dẫn cách xóa toàn bộ hình ảnh, video trong Google Photos tự động nhanh chóng https://gdrive.vip/cach-xoa-toan-bo-hinh-anh-video-trong-google-photos-nhanh-chong/
// Bạn muốn xóa bao nhiêu ảnh, video?
// Mặc định xóa tất cả
// Sửa ALL_PHOTOS thành số lượng muốn xóa, hoặc để nguyên để xóa tất cả
const maxImageCount = "ALL_PHOTOS";
// Nhấn nút chọn hình ảnh, video và xóa
const ELEMENT_SELECTORS = {
checkboxClass: '.ckGgle',
deleteButton: 'button[aria-label="Xoá"]',
languageAgnosticDeleteButton: 'div[data-delete-origin] > button',
deleteButton: 'button[aria-label="Xoá"]',
confirmationButton: '#yDmH0d > div.llhEMd.iWO5td > div > div.g3VIld.V639qd.bvQPzd.oEOLpc.Up8vH.J9Nfi.A9Uzve.iWO5td > div.XfpsVe.J9fJmf > button.VfPpkd-LgbsSe.VfPpkd-LgbsSe-OWXEXe-k8QpJ.nCP5yc.kHssdc.HvOprf'
}
// Tự động xóa toàn bộ hình ảnh, video trong Google Photos bởi https://gdrive.vip/
// Cấu hình thời gian (milliseconds)
const TIME_CONFIG = {
delete_cycle: 7000,
press_button_delay: 1000
};
const MAX_RETRIES = 10;
let imageCount = 0;
let checkboxes;
let buttons = {
deleteButton: null,
confirmationButton: null
}
let deleteTask = setInterval(() => {
let attemptCount = 1;
do {
checkboxes = document.querySelectorAll(ELEMENT_SELECTORS['checkboxClass']);
} while (checkboxes.length <= 0 && attemptCount++ < MAX_RETRIES);
if (checkboxes.length <= 0) {
console.log("[TRẠNG THÁI] Không còn hình ảnh (video) để xóa.");
clearInterval(deleteTask);
console.log("[THÀNH CÔNG] Đã thoát.");
return;
}
imageCount += checkboxes.length;
checkboxes.forEach((checkbox) => { checkbox.click() });
console.log("[TRẠNG THÁI] Đang xóa...", checkboxes.length, "hình ảnh/video");
setTimeout(() => {
try {
buttons.deleteButton = document.querySelector(ELEMENT_SELECTORS['languageAgnosticDeleteButton']);
buttons.deleteButton.click();
} catch {
buttons.deleteButton = document.querySelector(ELEMENT_SELECTORS['deleteButton']);
buttons.deleteButton.click();
}
setTimeout(() => {
buttons.confirmation_button = document.querySelector(ELEMENT_SELECTORS['confirmationButton']);
buttons.confirmation_button.click();
console.log(`[TRẠNG THÁI] ${imageCount}/${maxImageCount} đã xóa`);
if (maxImageCount !== "ALL_PHOTOS" && imageCount >= parseInt(maxImageCount)) {
console.log(`${imageCount} ảnh đã xóa theo yêu cầu`);
clearInterval(deleteTask);
console.log("[THÀNH CÔNG] Đã xóa tất cả hình ảnh và video của bạn.");
return;
}
}, TIME_CONFIG['press_button_delay']);
}, TIME_CONFIG['press_button_delay']);
}, TIME_CONFIG['delete_cycle']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment