How to accept all pending connection requests on LinkedIn using JavaScript?


To accept all pending connection requests on LinkedIn using JavaScript, you would need to use the LinkedIn API and an automation tool. The script would need to navigate to the connection request page and loop through each request, clicking the accept button for each one.

This is a very common issue for people who are moderately to highly active on Linkedin.

They get many connection requests every day and must manually click on accept against each request to actually accept them.

You can, however make use of JavaScript and the window console to automate this whole process and we will be covering the same today in this article.

Idea

The idea here is −

  • Log into your LinkedIn account in any modern web browser like Chrome, Firefox on a computer.

  • Right click anywhere on the screen and click on the inspect button.

  • The Developer tools window will open, now look for the console tab and click on it.

Now at the very bottom in this console tab, we can write our own JS code that will get executed for the current window.

Therefore, here is the code snippet that you will need to execute in order to accept all pending connection requests.

const acceptButtonClassName = '.invitation-card__action-btn.artdeco-button--secondary' const pendingConnections = document.querySelectorAll( acceptButtonClassName ); console.log(`Total requests: ${pendingConnections.length}`); for (let currentIndex = 0; currentIndex < pendingConnections.length; currentIndex++) { console.log(`Now accepting request ${currentIndex + 1}/${pendingConnections.length}`) pendingConnections[currentIndex].click(); }

Understanding the Code

What this code essentially does is that −

  • It defines a variable acceptButtonClassName which holds the name of the class that is common to all accept buttons and is not shared by any other element inside the DOM.

  • Then our code selects all the DOM elements (essentially all the accept buttons) using the document.querySelectorAll function.

  • And at the very end, we loop over each accept button, trigger the click function for each accept button and therefore accept each request.

Output

In my case I had only 5 pending requests, so the output generated was −

"Total requests: 5"
"Now accepting request 1/5"
"Now accepting request 2/5"
"Now accepting request 3/5"
"Now accepting request 4/5"
"Now accepting request 5/5"

Note − The output might vary for everyone based on the number of pending connection requests they have.

Updated on: 06-Feb-2023

317 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements