Skip to content

Instantly share code, notes, and snippets.

@Rayraegah

Rayraegah/robot_visitor.js

Last active Apr 10, 2018
Embed
What would you like to do?
linkedin connections visitor
// copypaste this script in console of page
// https://www.linkedin.com/mynetwork/invite-connect/connections/
//
// script to visit all connection pages on linkedin
// you may have to manually scroll the page to load all connection data
// or use the linkedin api
(function(){
// nodes containing profile url in href attribute
// linkedin now uses ember.js
const linkNodeList = document.querySelectorAll(".mn-connection-card__link");
// first profile
var i = 0;
// last profile
const numberOfProfiles = linkNodeList.length;
// time to wait before opening a new tab
// makes it look more human
const intervalBetweenNewTabs = 4000;
// time to wait before closing the profile tab
// trust me, it will break your browser otherwise
const waitBeforeTabClose = 10000;
// double check connections
// TODO: automate scroll, on the connections page linkedin says
// how many connections a profile hasat the top corner
// scroll page, timeout, checknode length untill this number
// is the same
console.log(`We've got ${numberOfProfiles} to visit this session.`)
// timeloop
var loop = setInterval(() => {
const profile = linkNodeList[i];
const newTab = window.open(profile.href);
// console.log(`opening page: ${profile.href}`);
setTimeout(() => {
newTab.close();
// print name of the vict- i mean connection
console.log(`visited: ${newTab.document.title}`)
}, waitBeforeTabClose)
i += 1;
if(i >= numberOfProfiles) {
// clear timeloop otherwise cats and puppies die
clearInterval(loop)
// console.groupEnd()
}
}, intervalBetweenNewTabs);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment