Advertisement
Guest User

Untitled

a guest
Nov 11th, 2019
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. // Unfollow everyone on twitter.com, by Jamie Mason (https://twitter.com/fold_left)
  2. // https://gist.github.com/JamieMason/7580315
  3. //
  4. // 1. Go to https://twitter.com/YOUR_USER_NAME/following
  5. // 2. Open the Developer Console. (COMMAND+ALT+I on Mac)
  6. // 3. Paste this into the Developer Console and run it
  7. (() => {
  8. const followButtonQuery = '[data-testid$="-unfollow"]';
  9. const confirmButtonQuery = '[data-testid="confirmationSheetConfirm"]';
  10. const sleep = ({ seconds }) =>
  11. new Promise(proceed => {
  12. console.log(`WAITING FOR ${seconds} SECONDS...`);
  13. setTimeout(proceed, seconds * 1000);
  14. });
  15.  
  16. const nextBatch = async () => {
  17. window.scrollTo(0, document.body.scrollHeight);
  18. await sleep({ seconds: 1 });
  19.  
  20. const followButtons = Array.from(document.querySelectorAll(followButtonQuery));
  21. const followButtonCount = followButtons.length;
  22.  
  23. if (followButtonCount === 0) {
  24. console.log(`NO ACCOUNTS FOUND, SO I THINK WE'RE DONE`);
  25. console.log(`RELOAD PAGE AND RE-RUN SCRIPT IF ANY WERE MISSED`);
  26. return;
  27. }
  28.  
  29. console.log(`UNFOLLOWING ${followButtonCount} USERS...`);
  30.  
  31. await Promise.all(
  32. followButtons.map(async followButton => {
  33. followButton.click();
  34. await sleep({ seconds: 1 });
  35. const confirmButton = document.querySelector(confirmButtonQuery);
  36. confirmButton.click();
  37. })
  38. );
  39.  
  40. await sleep({ seconds: 2 });
  41. nextBatch();
  42. };
  43.  
  44. nextBatch();
  45. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement