-
-
Save mi-lee/54a781dea746b947f36d8544682d3cdf to your computer and use it in GitHub Desktop.
// DISCLAIMER: I'VE ONLY RUN THIS SCRIPT ON MY OWN ACCOUNT ONLY. PROCEED/USE WITH RISK! I MADE THIS SCRIPT IN 20 MINUTES SO BE WARNED! | |
// On the other hand, I've deleted 50,000 comments in a matter of minutes so it's been pretty damn handy | |
// 1. Go to Activity feed, like facebook.com/<username>/allactivity | |
// 2. Navigate to specific section of FB, like "Likes and Reactions" or "Comments", | |
// like https://www.facebook.com/<username>/allactivity?privacy_source=activity_log&log_filter=cluster_<clusterid> | |
// 3. Navigate to year that you want to batch delete. You may need to scroll a little bit to let it load | |
// 4. Once you enter this there's no going back!! | |
// deletes, hides, and unlikes posts all within a specific year (in options.year) | |
function delete_hide_unlike(options) { | |
var rows = document.querySelectorAll('#facebook #year_' + options.year + ' ._42fu'); | |
for (var k = rows.length - 1; k >= options.limit; k--) { | |
var row = rows[k]; | |
var rowButton = row.click(); | |
var editButtons = document.querySelectorAll('._54nh'); | |
for (var j = editButtons.length - 1; j >= options.limit; j--) { | |
var editButton = editButtons[j]; | |
if (!editButton) { | |
console.log('Nope!'); | |
break; | |
} | |
if (editButton.textContent == 'Delete') { | |
editButton.click(); // COMMENT OUT IF YOU WANT TO TEST IT OUT WITHOUT ACTUALY DELETING | |
console.log("DELETED"); | |
} else if (editButton.textContent == 'Hidden from timeline') { | |
editButton.click(); // COMMENT OUT IF YOU WANT TO TEST IT OUT WITHOUT ACTUALY DELETING | |
console.log("HIDDEN"); | |
} else if (editButton.textContent == 'Unlike') { | |
editButton.click(); // COMMENT OUT IF YOU WANT TO TEST IT OUT WITHOUT ACTUALY DELETING | |
console.log("UNLIKE"); | |
} else { | |
console.log("IGNORED") | |
} | |
} | |
} | |
} | |
var options = { | |
year: '2007', | |
limit: 0, // use 1000 if you want to throttle how much to delete | |
} | |
delete_hide_unlike(options); | |
// unlikes and deletes anything that is globally public, by year (set in options.year) | |
function unlike_delete_globally_public_posts(options) { | |
var rows = document.querySelectorAll('#year_' + options.year + ' *[aria-label="Public"]') | |
for (var i = 0; i < rows.length; i++) { | |
var global_like = rows[i] | |
var likeButton = global_like.parentElement.parentElement.parentElement.querySelector('._42fu') | |
likeButton.click(); | |
var editButtons = document.querySelectorAll('._54nh'); | |
for (var j = editButtons.length - 1; j >= options.limit; j--) { | |
var editButton = editButtons[j]; | |
if (!editButton) { | |
console.log('Nope!'); | |
break; | |
} else if (editButton.textContent == 'Delete') { | |
editButton.click(); // COMMENT OUT IF YOU WANT TO TEST IT OUT WITHOUT ACTUALY DELETING | |
console.log("DELETED"); | |
} else if (editButton.textContent == 'Unlike') { | |
editButton.click(); // COMMENT OUT IF YOU WANT TO TEST IT OUT WITHOUT ACTUALY DELETING | |
console.log("UNLIKE"); | |
} else { | |
console.log("No action") | |
} | |
} | |
} | |
} | |
var options = { | |
year: '2009', | |
limit: 0 // use 1000 if you want to throttle it | |
} | |
unlike_delete_globally_public_posts(options) |
Any idea how to unlike only specific items using keyword and dates ? (Eg: unlike everything from website.com from 2017 to 2018)
Is there an update on this? But only for removing "likes and reactions" BUT not comments?
Thank you. :)
Could anybody please explain, how the coding needs to be changed and how to find out new object names with the new facebook website?
can you please update the script?
agreed - this is just what i"m looking for - but even with the "updated" script a few posts down from the top - i define the year and still get the undefined "error" at the bottom
Hello All
This is exactly what I was looking for but, can anyone please tell us where exactly to run the script? It may sound silly but I don't where to run it.
Thank you all.
@aalyassin - I don't think the script works at the moment, but this is how you're supposed to 'run' scripts.
open the script in an editor. change any options as required. copy the script.
open the appropriate FB page in your browser.
open the developer tools (F12), select console in the menu
paste the script into the console window/section.
@Lanterfanten Thank you.
This worked for me to unlike stuff (connections => pages, page likes...). May work for other logs too.
async function clear_fb() {
var rows = document.querySelectorAll('.kvgmc6g5 > .l9j0dhe7 .cypi58rs i')
for (const row of rows) {
// open
row.click()
// wait
await new Promise( resolve => {
setTimeout( () => {
resolve()
}, 100)
})
// confirm
document.querySelector('[role=menu] [role=menuitem]').click()
}
}
clear_fb()
@TobiaszCudnik Thank you! works flawlessly 😌
This clears a specific date:
START
await (async function clear_fb(dateTextFilter) {
var count = 0;
var accumulator = 0;
async function wait(time = 16) {
await new Promise((resolve) => {
setTimeout(() => {
resolve();
}, time);
});
}
async function try_click(element) {
if (!element) return;
try {
element.scrollTo();
await wait(1);
} catch (e) {}
try {
element.focus();
await wait(1);
} catch (e) {}
try {
element.click();
await wait();
} catch (e) {}
}
async function do_clear() {
window.scrollTo(0, document.body.scrollHeight);
await wait(500);
var parent = [...document.querySelectorAll(".bi6gxh9e")].filter((e) =>
e.innerText.includes(dateTextFilter)
)[0].parentElement;
var rows = [
...parent.querySelectorAll(".kvgmc6g5 > .l9j0dhe7 .cypi58rs i"),
];
console.log("Discovered " + rows.length + " rows");
for (const row of rows) {
await try_click(row);
console.log(row.parentElement.parentElement.parentElement.innerText);
var unlike = document.querySelector("[role=menu] [role=menuitem]");
await try_click(unlike);
var ok = [
...document.querySelectorAll(
".a8c37x1j.ni8dbmo4.stjgntxs.l9j0dhe7.ltmttdrg.g0qnabr5"
),
].filter((e) => e.innerText.includes("OK"))[0];
await try_click(ok);
var x = [
...document.querySelectorAll(
"div.rq0escxv.l9j0dhe7.du4w35lb.j83agx80.cbu4d94t.pfnyh3mw.d2edcug0.hpfvmrgz.p8fzw8mz.pcp91wgn.iuny7tx3.ipjc6fyt > div > i"
),
][0];
await try_click(x);
row.parentElement.parentElement.parentElement.remove();
await wait();
}
return rows.length;
}
do {
window.scrollTo(0, 0);
await wait();
count = await do_clear();
accumulator += count;
console.log("Finished clearing " + accumulator + " rows");
} while (count != 0);
console.log("Done");
})("February 28, 2022");
END
Not future proof at all, but does the job for now.
@DeanyBox you run it in the browser console directly (in Developer Tools).
Wish I'd had this years ago; I tried all sorts of plugins and scripts to delete FB activity, and some of them worked quite well -- for a short time, until Zucky changed the code so they wouldn't work. Moot point now, though, because I finally utilized the nuclear option and deleted my FB, Insta, and WhatsApp about six months ago. You can do it, too! :)
Can someone please show me how this is supposed executed in console, I copied and pasted into console but i think the reason its not working is because i might be adding text that i shouldn’t be?
// deletes, hides, and unlikes posts all within a specific year (in options.year)
function delete_hide_unlike(options) {
var rows = document.querySelectorAll('#facebook #year_' + options.year + ' ._42fu');
for (var k = rows.length - 1; k >= options.limit; k--) {
var row = rows[k];
var rowButton = row.click();
var editButtons = document.querySelectorAll('._54nh');
for (var j = editButtons.length - 1; j >= options.limit; j--) {
var editButton = editButtons[j];
if (!editButton) {
console.log('Nope!');
break;
}
if (editButton.textContent == 'Delete') {
editButton.click(); // COMMENT OUT IF YOU WANT TO TEST IT OUT WITHOUT ACTUALY DELETING
console.log("DELETED");
} else if (editButton.textContent == 'Hidden from timeline') {
editButton.click(); // COMMENT OUT IF YOU WANT TO TEST IT OUT WITHOUT ACTUALY DELETING
console.log("HIDDEN");
} else if (editButton.textContent == 'Unlike') {
editButton.click(); // COMMENT OUT IF YOU WANT TO TEST IT OUT WITHOUT ACTUALY DELETING
console.log("UNLIKE");
} else {
console.log("IGNORED")
}
}
}
}
var options = {
year: '2007',
limit: 0, // use 1000 if you want to throttle how much to delete
}
delete_hide_unlike(options);
// unlikes and deletes anything that is globally public, by year (set in options.year)
function unlike_delete_globally_public_posts(options) {
var rows = document.querySelectorAll('#year_' + options.year + ' *[aria-label="Public"]')
for (var i = 0; i < rows.length; i++) {
var global_like = rows[i]
var likeButton = global_like.parentElement.parentElement.parentElement.querySelector('._42fu')
likeButton.click();
var editButtons = document.querySelectorAll('._54nh');
for (var j = editButtons.length - 1; j >= options.limit; j--) {
var editButton = editButtons[j];
if (!editButton) {
console.log('Nope!');
break;
} else if (editButton.textContent == 'Delete') {
editButton.click(); // COMMENT OUT IF YOU WANT TO TEST IT OUT WITHOUT ACTUALY DELETING
console.log("DELETED");
} else if (editButton.textContent == 'Unlike') {
editButton.click(); // COMMENT OUT IF YOU WANT TO TEST IT OUT WITHOUT ACTUALY DELETING
console.log("UNLIKE");
} else {
console.log("No action")
}
}
}
}
var options = {
year: '2009',
limit: 0 // use 1000 if you want to throttle it
}
unlike_delete_globally_public_posts(options)
@mi-lee Hello :) I have tried all scripts but it's not working. I think it needs an update to the new Facebook, Could you please recheck the script? I just need interactions (post likes/comment likes) remover. Thanks in advance :)
@Meligy Hello :) the script you wrote is not working, could you please update it, just specific to the year (not specific to a date)? It gave me undefined result, as of a specific date too. Thanks!
you need to set the proper date in the options and @andrewtheis there is a typo, seems like now it's "Remove reaction" without capital R in the reaction :)
@lanceLMD15 run: