Reference Script : https://gist.github.com/aymericbeaumet/d1d6799a1b765c3c8bc0b675b1a1547d
Make sure check and support his work in link above!
Don't forget follow me on twitter : https://twitter.com/astin_rai
Thank You
Warning!
If the image or video media is no longer visible and the number of images and videos are still visible under your X(Twitter) name after using this script you must wait at least 1 week or more to continue using this script.
//Make sure open your twitter Profile and go to Media
//Only Work On Desktop Mode!
(() => {
const scrollToTheBottom = () => window.scrollTo(0, document.body.scrollHeight);
const retry = {
count: 0,
limit: 3,
};
const addNewRetry = () => retry.count++;
const retryLimitReached = () => retry.count === retry.limit;
const sleepToNextBatch = 10; //Should not be less than 10 seconds to avoid shadowban
const sleep = ({ proggress,seconds }) =>
new Promise((proceed) => {
console.log(`${proggress}`);
console.log(`WAITING FOR ${seconds} SECONDS...`);
setTimeout(proceed, seconds * 1000);
});
const deleteImage = async () => {
await sleep({ proggress: "Click Media" ,seconds: 2 });
await document.querySelectorAll("li[role='listitem']")[0].querySelector("a[role='link']").click();
await sleep({ proggress: "Check If Sidebar Available" ,seconds: 2 });
if(document.querySelector("button[aria-label='View post'")) {
document.querySelector("button[aria-label='View post'").click();
}
await sleep({ proggress: "Click Button More" ,seconds: 2 });
const moreMenu = document.querySelectorAll("button[aria-label='More']");
for (const menu of moreMenu) {
menu.click();
}
await sleep({ proggress: "Click Delete" ,seconds: 2 });
Array.prototype.slice.call(document.querySelectorAll("div[role='menuitem']"))
.filter(function (el) {
return el.textContent === 'Delete' //Change 'Delete' by your language like Delete in Indonesian is 'Hapus' and must be in Sentence Case
})[0].click();
await sleep({ proggress: "Confirm Delete" ,seconds: 2 });
await document.querySelectorAll('button[data-testid="confirmationSheetConfirm"]')[0].click();
await sleep({ proggress: "Force Close Media Dialog" ,seconds: 2 });
if(document.querySelector("div[role='dialog'")) {
await document.querySelector("div[role='dialog'").querySelector("button[aria-label='Close']").click();
}
await sleep({ proggress: "Remove Media In List Item" ,seconds: 2 });
await document.querySelector("li[role='listitem']").remove();
}
const nextBatch = async () => {
await sleep({ proggress: "Sleeping.....", seconds: sleepToNextBatch });
await sleep({ proggress: "Checking Media...", seconds: 1 });
const itemImageList = Array.from(document.querySelectorAll("section[role='region']")[0].querySelectorAll("li[role='listitem']"));
const itemImageFound = itemImageList.length > 0;
if (itemImageFound) {
await sleep({ proggress: "Media Found!", seconds: 1 });
await deleteImage();
await sleep({ proggress: "Proggress to next batch", seconds: 2 });
return nextBatch();
} else {
scrollToTheBottom();
addNewRetry();
}
if (retryLimitReached()) {
console.log(`NO MEDIA FOUND, SO I THINK WE'RE DONE`);
console.log(`RELOAD PAGE AND RE-RUN SCRIPT IF ANY WERE MISSED`);
} else {
await sleep({ proggress: "Proggress to next batch", seconds: 2 });
return nextBatch();
}
};
nextBatch();
})();
kenapa ga bekerja ya kak?