Created
July 22, 2010 20:04
-
-
Save simonw/486505 to your computer and use it in GitHub Desktop.
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
/* Evil script for exporting LinkedIn contacts along with their locations. | |
Navigate to http://www.linkedin.com/connections?trk=hb_tab_cnts and | |
click on the "Locations" accordion button, then paste the following | |
script in to the Google Chrome JavaScript console (untested in anything | |
else). After quite a while a popup with some JSON will appear. */ | |
function fakeClick(el) { | |
var e = document.createEvent('MouseEvents'); | |
e.initEvent('click', true, true); | |
el.dispatchEvent(e); | |
} | |
var location_lis = document.querySelectorAll( | |
'ul#abook-filter-accordion li.section' | |
)[2].getElementsByTagName('li'); | |
var location_lis_array = []; | |
for (var i = 0, j = location_lis.length; i < j; i++) { | |
location_lis_array[i] = location_lis[i]; | |
} | |
var results = []; | |
function doNext() { | |
if (!location_lis_array.length) { | |
prompt('Copy me!', JSON.stringify(results)); | |
} | |
var li = location_lis_array.shift(); | |
var loc = li.innerText; | |
fakeClick(li); | |
setTimeout(function() { | |
var people = document.querySelectorAll( | |
'#list-panel div.conn-wrapper' | |
); | |
for (var person, k = 0; person = people[k]; k++) { | |
var id = person.parentNode.id; | |
results[results.length] = { | |
location: loc, | |
name: person.getElementsByTagName( | |
'input' | |
)[0].value, | |
photo: person.getElementsByClassName( | |
'conn-photo' | |
)[0].getElementsByTagName('img')[0].src, | |
title: person.getElementsByClassName( | |
'conn-headline' | |
)[0].innerText, | |
url: 'http://www.linkedin.com/profile?viewProfile=&key=' + id | |
} | |
} | |
doNext(); | |
}, 7000); | |
} | |
doNext(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment