ล่าสุดกำลังจะ Revamp ทวิตเตอร์เมื่อ 5 ปีที่แล้วใหม่หมดของเพจ Designil.com พอไปเช็คก็พบว่ามี follow คนฝรั่งอยู่ 300 กว่าคน ซึ่งหน้าตาเป็นแสปมทั้งนั้น ไม่รู้ไป Follow ตอนไหน
ซึ่งหลังจากลองหา Tool Online บนเว็บไซต์มา 2-3 ตัว และ Research ใน Quora ก็พบว่าแต่ละตัวใช้ยากบ้าง ดึงข้อมูลนานบ้าง ไม่สำเร็จสักทีกับการ Unfollow คน 300 คน (ตอนแรกเกือบจะไปนั่งกดเองแล้ว แต่พอดี Twitter ออกแบบหน้าใหม่ให้กด Unfollow ยากขึ้นมาก)

สังเกตว่าการจะกด Unfollow ทั้งหมดต้องกดทีละคนจากซ้ายไปขวา ซึ่งจะได้แค่แถวละ 3 คน ต้องขยับเม้าส์หลายทิศทางมากกว่าจะ Unfollow หมด ซึ่งถ้า UX แบบดี ๆ ให้กดง่าย ๆ จะต้องแสดงเป็น 1 คน 1 แถวแทน และให้ปุ่ม Unfollow เรียงกันลงมา จะกดง่ายมากเพราะไม่ต้องเปลี่ยนทิศทาง (ดูรูปประกอบด้านล่าง)

แน่นอนว่าเราเป็น Developer ต้องไม่ยอมแพ้ Twitter ครับ ผมเคยเห็นสคริปต์ลากเพื่อนเข้ากรุ๊ป Facebook แบบรวดเร็ว ซึ่งเป็น Javascript และคิดว่าการ Unfollow Twitter รัว ๆ ก็สามารถใช้ Javascript ได้เช่นเดียวกัน เลยไปเสิร์จ Google
ซึ่งก็เจอฝรั่งหัวใสแจกสคริปต์นี้ออกมาครับ ! เอาไปรันใน Console แล้วจะ Unfollow หมดเลย
// 1. Go to https://twitter.com/following. // 2. Keep scrolling to the bottom repeatedly until all your followers are loaded. // 3. Run this in your console. [].slice.call(document.querySelectorAll('.unfollow-text')).forEach(function(button) { button.click(); });
หลักการทำงานมันก็คือ
- ไปที่หน้ารวม Following ของเรา http://www.twitter.com/following
- เลื่อนให้ถึงล่างสุดให้โหลด Following จนหมด
- รันสคริปต์ด้านบนนี้ใน Console (Windows – กด F12 ใน Firefox / Chrome, Mac – กด Cmd + Opt + i ใน Firefox / Chrome เพื่อเปิด Console)
เพียงเท่านี้สคริปต์จะทำการกด Unfollow ทุกคนให้เราเรียบร้อยครับ สบาย ๆ
เครดิต:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Unfollow everyone on twitter.com, by Jamie Mason (https://twitter.com/fold_left) | |
// https://gist.github.com/JamieMason/7580315 | |
// | |
// 1. Go to https://twitter.com/YOUR_USER_NAME/following | |
// 2. Open the Developer Console. (COMMAND+ALT+I on Mac) | |
// 3. Paste this into the Developer Console and run it | |
// | |
// Last Updated: 09 April 2020 | |
(() => { | |
const $followButtons = '[data-testid$="-unfollow"]'; | |
const $confirmButton = '[data-testid="confirmationSheetConfirm"]'; | |
const retry = { | |
count: 0, | |
limit: 3, | |
}; | |
const scrollToTheBottom = () => window.scrollTo(0, document.body.scrollHeight); | |
const retryLimitReached = () => retry.count === retry.limit; | |
const addNewRetry = () => retry.count++; | |
const sleep = ({ seconds }) => | |
new Promise((proceed) => { | |
console.log(`WAITING FOR ${seconds} SECONDS…`); | |
setTimeout(proceed, seconds * 1000); | |
}); | |
const unfollowAll = async (followButtons) => { | |
console.log(`UNFOLLOWING ${followButtons.length} USERS…`); | |
await Promise.all( | |
followButtons.map(async (followButton) => { | |
followButton && followButton.click(); | |
await sleep({ seconds: 1 }); | |
const confirmButton = document.querySelector($confirmButton); | |
confirmButton && confirmButton.click(); | |
}) | |
); | |
}; | |
const nextBatch = async () => { | |
scrollToTheBottom(); | |
await sleep({ seconds: 1 }); | |
const followButtons = Array.from(document.querySelectorAll($followButtons)); | |
const followButtonsWereFound = followButtons.length > 0; | |
if (followButtonsWereFound) { | |
await unfollowAll(followButtons); | |
await sleep({ seconds: 2 }); | |
return nextBatch(); | |
} else { | |
addNewRetry(); | |
} | |
if (retryLimitReached()) { | |
console.log(`NO ACCOUNTS FOUND, SO I THINK WE'RE DONE`); | |
console.log(`RELOAD PAGE AND RE-RUN SCRIPT IF ANY WERE MISSED`); | |
} else { | |
await sleep({ seconds: 2 }); | |
return nextBatch(); | |
} | |
}; | |
nextBatch(); | |
})(); |