The LinkedIn “Endorsing” Problem and Solution
The Problem.
I use LinkedIn to connect with people that I think have integrity. I want to show them my support by endorsing their skills, but I’ve accrued too many connections to afford the time.
The Solution.
Using 2 programming languages, one program, and two program extensions: I can endorse them all.
That’s a long list of requirements so if you have a better way, I guess you should go for it! Oh wait, you don’t. Neither does anyone who’s willing to share it. You can go Google your life away now.
Still here? Sweet! Here’s what we’ll need:
- Firefox ESR (Any version on the ESR channel, or prior to the multiprocess changes in the Electrolysis implementation in 49~). I used version 45.7.0 ESR.
- iMacros for Firefox. Any version. I used 9.0.3.
- GreaseMonkey for Firefox. Any version.
- A text editor. I use Atom.
- That’s all. Lists are just better with at least three items.
If you think that you’re technical enough to get set up with just this list and the source code, visit or clone my GitHub repository here.
Changelog: Due to LinkedIn frequently updating their website’s User Interface, the code snippets below may have become outdated.
- 2018.04.09 – iMacros updates to bypass LI’s new “Auth Wall” authentication.
- 2018.01.10 – CSS selector updates corresponding to LI UI updates.
Scrape Your Connection’s URLs
First and foremost, we’re going to scrape URLs to your connection’s profiles into a CSV file using the Chrome console (Or Firefox). Open this web page and paste the following into the console.
Error.stackTraceLimit = Infinity; for(var x = 0; x < 89000; x += 500){ setTimeout(() => window.scrollTo(0,document.body.scrollHeight), x); } setTimeout(() => { $(".mn-connection-card__link").each((x, e) => console.log(e.href)) }, 90000);
This Javascript code reports all of your connection’s profiles URLs back to the console! It first scrolls down the page for one minute because LinkedIn developers used a lazy loading AJAX technique on this page.
Right click on the console output, and click “Save As”. Go to the file and clean up anything in it that isn’t a URL or a newline character. Then, create a new CSV file in the root of you iMacros directory and paste the data into the CSV file. Save it!
Write an iMacros Script to Iterate the Profiles
Open the iMacros extension and paste the following into a new macro. LIC.csv is the name of my CSV file.
VERSION BUILD=9030808 RECORDER=FX SET !ERRORIGNORE YES SET !TIMEOUT_STEP 10 SET !EXTRACT_TEST_POPUP NO TAB CLOSEALLOTHERS SET !LOOP 1 SET !DATASOURCE LIC.csv SET !DATASOURCE_LINE {{!LOOP}} CLEAR URL GOTO={{!COL1}} WAIT SECONDS=2 EVENT TYPE=CLICK SELECTOR="HTML>BODY>DIV>MAIN>DIV>DIV>FORM:nth-of-type(2)>P:nth-of-type(3)>A" BUTTON=0 WAIT SECONDS=2 TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:https://www.linkedin.com/uas/login-submit ATTR=* WAIT SECONDS=20
This code will navigate from one profile page to another, after waiting on each page for 15 seconds. During those 15 seconds, Javascript code will execute to do the actual endorsing – which leads me to the next part.
Write JS for GreaseMonkey to Endorse each Connection
Create a new user script and make the include and match patterns this: https://www.linkedin.com/in/*
Then paste the following code into the user script.
// ==UserScript== // @name Endorse // @namespace LinkedIN // @include https://www.linkedin.com/in/* // @version 1 // @grant none // ==/UserScript== setTimeout(() => { for(var x = 0; x < 9000; x += 1000){ setTimeout(() => {window.scrollTo(0,document.body.scrollHeight);}, x); } }, 5000); setTimeout(() => { $("button[data-control-name='skill_details']").click(); $("button[data-control-name='endorse']").each((x, e) => { if(x < 40){$(e).click();} else {return;} }); }, 15000);
This code scrolls to the bottom of the page for 9 seconds – again, this page uses the lazy loading AJAX technique. Then, it expands an area containing the skills and their respective endorsing buttons. Once exposed, the top 40 skills that aren’t already endorsed, are endorsed. Only 40 can be endorsed at a time without violating LinkedIn’s AJAX request limitation. To endorse the next 40 skills in your connections list, just run the script again. Most people won’t have over 40 skills listed.
Run the iMacros Script and Watch the Magic.
Count the lines in your CSV file, and loop the iMacros script that many times. Once it starts looping, you can watch your connections receive your unfettered love for them.
This concludes today’s LinkedIn lecture! 😉