Get Google Search queries for your Twitter lists
by Alessandro Vernet
HTML
<script src="http://jashkenas.github.com/coffee-script/extras/coffee-script.js"></script>
Username: <input id="username" value="avernet">
<ol id="lists"></ol>
<script type="text/coffeescript">
username = ($ "#username").val()
apiBase = "http://api.twitter.com/1/#{username}"
getListMembers = (listNames, callback) ->
lists = {}
listName = listNames.shift()
list = []
nextCursor = 0
worker = () ->
cursor = if nextCursor is 0 then "" else "cursor=#{nextCursor}&"
query = "#{apiBase}/#{listName}/members.json?#{cursor}callback=?"
$.getJSON query, (result) ->
list.push user.screen_name for user in result.users
nextCursor = result.next_cursor
if nextCursor is 0
lists[listName] = list
list = []
listName = listNames.shift()
if listName then worker() else callback(lists)
worker()
getListNames = (callback) ->
$.getJSON "#{apiBase}/lists.json?callback=?", (result) ->
callback (list.name for list in result.lists)
displayLists = (lists) ->
ol = $ "#lists"
for listName, members of lists
search = ""
for member in members
search += " OR " if search isnt ""
search += "site:twitter.com/#{member}"
li = $ "<li>"
li.append "<i>#{listName} (#{members.length}):</i> site:#{listName} OR #{search}"
ol.append li
getListNames (listNames) -> getListMembers listNames, (lists) -> displayLists lists
</script>
CSS
body { font-family: sans-serif }