Skip to content

Instantly share code, notes, and snippets.

@joaocarmo
Created April 19, 2025 16:57
Show Gist options
  • Select an option

  • Save joaocarmo/eb32e48803108a4c239edfedd1fc0285 to your computer and use it in GitHub Desktop.

Select an option

Save joaocarmo/eb32e48803108a4c239edfedd1fc0285 to your computer and use it in GitHub Desktop.
This script can be executed directly in the browser's console, while visiting Flickr's groups list, to leave all groups
const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
const leaveOneGroup = async (row) => {
const event = new MouseEvent("click", {
bubbles: true,
cancelable: true,
view: window,
});
const moreButton = row.querySelector(".icon-more_horizontal");
moreButton.dispatchEvent(event);
await wait(1_000);
const leaveGroupOption = [
...document.querySelectorAll('[role="menuitem"]'),
].find((el) => el.textContent.includes("Leave Group"));
leaveGroupOption.click();
await wait(1_000);
const confirmRemoveCheckbox = [...document.querySelectorAll("label")].find(
(el) => el.textContent.includes("Also remove all the photos")
);
confirmRemoveCheckbox.click();
await wait(1_000);
const okButton = [...document.querySelectorAll("button")].find((el) =>
el.textContent.includes("OK")
);
okButton.click();
};
const leaveAllGroups = async () => {
let groupRows = [...document.querySelectorAll("tr[data-group-nsid]")];
while (groupRows.length > 0) {
await leaveOneGroup(groupRows[0]);
await wait(5_000);
groupRows = [...document.querySelectorAll("tr[data-group-nsid]")];
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment