Skip to content

Instantly share code, notes, and snippets.

@phixion
Last active September 20, 2026 00:29
Show Gist options
  • Select an option

  • Save phixion/defaf3684b201f00352fd3afcb6d0dcc to your computer and use it in GitHub Desktop.

Select an option

Save phixion/defaf3684b201f00352fd3afcb6d0dcc to your computer and use it in GitHub Desktop.
delete-insta-likes
// Instagram doesn't allow to select all your posts, or all your comments, etc. to delete them.
// You can only select them one by one. This is slow as hell.
// Use this to select all the photos, comments, etc.
// 1. Open this page: https://www.instagram.com/your_activity/interactions/likes/
// 2. Press the F12 key to open the developer tools
// 3. open the console tab in the developer tools
// 4. copy-paste the following code in the command prompt of the console and press enter
(async function autoLoopRemoveLikes() {
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
const triggerClick = (el) => {
["mousedown", "mouseup", "click"].forEach((eventType) => {
el.dispatchEvent(
new MouseEvent(eventType, {
bubbles: true,
cancelable: true,
view: window,
}),
);
});
};
const findButtonByText = (text) => {
return Array.from(document.querySelectorAll("div, button, span")).find(
(el) =>
el.children.length === 0 &&
el.textContent.trim().toLowerCase() === text.toLowerCase(),
);
};
while (true) {
console.log("starting new run");
const selectBtn =
findButtonByText("Auswählen") || findButtonByText("Select");
if (selectBtn) {
triggerClick(selectBtn.closest('div[role="button"]') || selectBtn);
await delay(200);
}
const icons = Array.from(document.querySelectorAll("div.wbloks_1")).filter(
(el) => (el.getAttribute("style") || "").includes("circle__outline"),
);
if (icons.length === 0) {
console.log("wait 7 seconds...");
await delay(7000);
continue;
}
for (const icon of icons) {
const target =
icon.closest('div[role="button"]') ||
icon.closest('div[tabindex="0"]') ||
icon.parentElement?.parentElement;
if (target) {
let retries = 0;
while (
(icon.getAttribute("style") || "").includes("circle__outline") &&
retries < 3
) {
triggerClick(target);
retries++;
await delay(40);
}
}
}
await delay(150);
const initialUnlike =
findButtonByText("Gefällt mir nicht mehr") || findButtonByText("Unlike");
if (initialUnlike) {
triggerClick(
initialUnlike.closest('button, div[role="button"]') || initialUnlike,
);
}
let attempts = 0;
while (attempts < 5) {
await delay(200);
const popupBtn =
document.querySelector("button._a9--._ap36._a9_1") ||
document.querySelector("button._a9--") ||
findButtonByText("Gefällt mir nicht mehr") ||
findButtonByText("Unlike");
if (!popupBtn) break;
triggerClick(popupBtn);
attempts++;
}
console.log("finished! waiting 7 seconds...");
await delay(7000);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment