Browser Automation · LinkedIn

Tired of Clicking "Accept"? How to Safely Automate LinkedIn Invites (Without Getting Banned)

Why most console scripts get accounts restricted โ€” and a human-mimicking version that won't.

We've all been there: you open LinkedIn after a week away, and you're greeted by a mountain of pending connection requests. Clicking "Accept" dozens of times is a tedious chore.

Naturally, being the tech-savvy people we are, the first instinct is to find a quick JavaScript snippet to paste into the browser console to do the heavy lifting.

But here is a massive warning: most LinkedIn automation scripts you find online will get your account restricted or permanently banned.

Here is why those random scripts are dangerous, and how you can use a cleaned, "human-mimicking" version safely.

๐Ÿ›‘ The Hidden Danger of Basic Automation Scripts

If you grab a generic script off GitHub or StackOverflow, it usually works by finding every "Accept" button on the page and clicking them all at once using something called parallel execution (Promise.all).

To LinkedIn's security algorithms, this screams BOT. No human can click 10 buttons at the exact same millisecond. When LinkedIn catches this unnatural behavior, they put your account in "LinkedIn Jail" (temporary or permanent restriction).

To do this safely, we need a script that acts like a human: scrolling down, pausing to "think," and clicking buttons one by one with random intervals.

๐Ÿงผ The Safe Solution: The "Human-Mimicking" Script

Here is a cleaned-up, safe version of the script. It processes invites sequentially, adds randomized delays between clicks, and includes a safety hard-stop so it won't loop infinitely if LinkedIn's code glitches.

(async function () {
  console.log("๐Ÿš€ Starting safe LinkedIn request accept script...");

  // Helper to pause execution
  const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));

  // Generates a random number between min and max (for chaotic human delays)
  const rand = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;

  let totalAccepted = 0;
  let cycle = 0;
  const MAX_CYCLES = 10; // Safety guard to prevent infinite loops

  while (cycle < MAX_CYCLES) {
    cycle++;
    console.log(`๐Ÿ”„ Cycle ${cycle} of ${MAX_CYCLES}`);

    // Find all Accept/Confirm buttons
    const acceptButtons = Array.from(document.querySelectorAll('button'))
      .filter(btn => {
        const text = btn.innerText.trim().toLowerCase();
        return text === 'accept' || text === 'confirm'; // Strict matching
      });

    console.log(`๐Ÿ” Found ${acceptButtons.length} pending invites in this view.`);

    if (acceptButtons.length === 0) {
      // If no buttons found, try to load more content
      const loadMoreBtn = Array.from(document.querySelectorAll('button'))
        .find(btn => btn.innerText.trim().toLowerCase().includes('load more'));

      if (loadMoreBtn) {
        console.log("โฌ‡ Clicking 'Load more'...");
        loadMoreBtn.click();
        // Wait a random 2-4 seconds for content to load
        await sleep(rand(2000, 4000));
        continue;
      } else {
        console.log("โœ… No more invites or 'Load more' buttons found.");
        break;
      }
    }

    // Process buttons sequentially with human-like delays
    for (const btn of acceptButtons) {
      try {
        // Scroll the button into view so it looks like a human is browsing
        btn.scrollIntoView({ behavior: 'smooth', block: 'center' });

        // Wait a moment after scrolling before clicking (1 to 2.5 seconds)
        await sleep(rand(1000, 2500));

        btn.click();
        totalAccepted++;
        console.log(`โœ” Accepted #${totalAccepted}`);

        // Pause *after* the click before moving to the next one (1.5 to 3.5 seconds)
        await sleep(rand(1500, 3500));
      } catch (err) {
        console.warn("โš  Skipped a button due to an error:", err.message);
      }
    }
  }

  console.log(`๐ŸŽ‰ Script finished. Total accepted: ${totalAccepted}`);
})();

๐Ÿ›  How to Save This Permanently (No Copy-Pasting Every Time)

Instead of copying and pasting this code into the console every single time, you can save it as a Snippet right inside your browser's Developer Tools.

Step 1: Save the Snippet

  1. Go to your LinkedIn invitations page.
  2. Press F12 (or right-click and select Inspect) to open Developer Tools.
  3. Click on the Sources tab at the top.
  4. On the left navigation pane, look for the Snippets sub-tab (if you don't see it, click the double arrow >> to reveal hidden tabs).
  5. Click + New snippet, name it LinkedIn_Accept, and paste the code above into the main window.
  6. Press Ctrl + S (or Cmd + S on Mac) to save it.

Step 2: How to Run It

Whenever you land on your invite page in the future, just open your DevTools (F12), go to Sources > Snippets, right-click your LinkedIn_Accept snippet, and click Run.

You can sit back and watch the Console log your progress while the browser safely clears out your inbox!

โš ๏ธ A Friendly Disclaimer: Even though this script is designed to look like a real person browsing, automation technically violates LinkedIn's User Agreement. Don't abuse it by running it to accept hundreds of connections multiple times a day. Use it moderately to clear out weekly build-ups, and your account will stay perfectly safe!