Skip to content

Instantly share code, notes, and snippets.

@maifeeulasad
Created May 17, 2026 12:47
Show Gist options
  • Select an option

  • Save maifeeulasad/34fa82cf13426599cfe02bc028f74365 to your computer and use it in GitHub Desktop.

Select an option

Save maifeeulasad/34fa82cf13426599cfe02bc028f74365 to your computer and use it in GitHub Desktop.
Remove saved posts from linkedin with this script

goto linkedin, click on saved item, keep the pgdn button for few minutes now it's time to execute the script

(async () => {
// Find all "more actions" buttons
const buttons = Array.from(
document.querySelectorAll(
'button[aria-label*="take more actions"]'
)
);
console.log(`Found ${buttons.length} buttons`);
// Small helper
const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
for (let i = 0; i < buttons.length; i++) {
const button = buttons[i];
try {
console.log(`Processing ${i + 1}/${buttons.length}`);
// Scroll into view
button.scrollIntoView({
behavior: "smooth",
block: "center",
});
await wait(700);
// Open dropdown
button.click();
await wait(1000);
// Find "Unsave" option
const unsaveElement = Array.from(
document.querySelectorAll("span.image-text-lockup__text")
).find(
(el) => el.textContent.trim().toLowerCase() === "unsave"
);
if (unsaveElement) {
console.log("Found Unsave button");
// Click closest clickable parent
const clickable =
unsaveElement.closest('[role="button"]') ||
unsaveElement.closest("button") ||
unsaveElement.parentElement;
clickable.click();
console.log("Clicked Unsave");
await wait(1000);
} else {
console.log("Unsave button not found");
// Close dropdown by clicking outside
document.body.click();
await wait(500);
}
} catch (err) {
console.error("Error processing button:", err);
}
}
console.log("Done!");
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment