Working with your Twitter Followers/Following lists

This post is about how to get a simple list of Twitter Followers/Following that you can work with, using the data that’s already available for you – on your own browser.  It’s a concept similar to how bookmarklets work, but this approach doesn’t involve installing anything on your machine.

This quick solution runs on your own Chrome browser,  requires no API dev work, requires nothing to be installed, requires no additional page requests, and requires no 3rd-party services. It’s very simple, you control it, and it uses your browser’s own inspection tools. It’s just Javascript using XPath to navigate the page’s DOM.

  1. Use Chrome (it might work with other browsers, but haven’t checked);
  2. Go to the followers/following section and scroll all the way to the bottom so they’re all visible on the page;
  3. Right click the web page and choose “Inspect”;Screen Shot 2016-08-12 at 12.45.18 PM
  4. You’ll see something like what I’m showing here. Click on Console; Screen Shot 2016-08-12 at 12.37.20 PM
  5. Paste the following Javascript code on the prompt and press Return/Enter. Note that it’s one very long line;

a=$x("//div[@class='ProfileCard-userFields']");b=[];for(var i=0;i<a.length;i++){b.push("@"+$x(".//span[@class='u-linkComplex-target']/text()",a[i])[0].textContent+"\t"+$x(".//a[contains(@class,'ProfileNameTruncated-link')]/text()",a[i])[0].textContent.replace(/(^\s+|\s+$)/g,''));b.join("\n")}

As a result, you get a newline-separated list of handles and names that can be easily copied, and then pasted into a text editor or spreadsheet. Handles and names are separated with tabs so you can easily separate the data into columns for filtering and/or sorting.

This seems to work fine today… but if the design of the page loaded by your browser changes, this will likely stop working.