Advertisement
praveen42

Unfollow all on Linkedin

Apr 25th, 2021
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (() => {
  2.   let count = 0;
  3.  
  4.   function getAllButtons() {
  5.     return document.querySelectorAll('button.is-following') || [];
  6.   }
  7.  
  8.   async function unfollowAll() {
  9.     const buttons = getAllButtons();
  10.  
  11.     for (let button of buttons) {
  12.       count = count + 1;
  13.  
  14.       const name = button.parentElement.querySelector(
  15.         '.follows-recommendation-card__name',
  16.       ).innerText;
  17.       console.log(`Unfollow #${count}:`, name);
  18.  
  19.       window.scrollTo(0, button.offsetTop - 260);
  20.       button.click();
  21.  
  22.       await new Promise((resolve) => setTimeout(resolve, 100));
  23.     }
  24.   }
  25.  
  26.   async function run() {
  27.     await unfollowAll();
  28.     window.scrollTo(0, document.body.scrollHeight);
  29.     await new Promise((resolve) => setTimeout(resolve, 1000));
  30.  
  31.     const buttons = getAllButtons();
  32.     if (buttons.length) run();
  33.   }
  34.  
  35.   run();
  36. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement