Question: I'm looking for a way to auto connect to people found via the LinkedIn advanced search function. There's plenty of information on doing this from the 'people you may know' page but I can only find the code below that is meant to work on the advanced search page, but doesn't. Any ideas?

```
setInterval(function () {var x = $(‘.primary-action-button’);for (var i = 0; i < x.length; i++){if(x[i].innerHTML == “Connect”) {x[i].click()}}var y = $(‘a.page-link’);y[y.length — 1].click();}, 1000)

```

Answer: 
```
var i;
var res;
var str1 = "ember";
for(i=0;i < 10000;i++)
{
try {
    res = str1.concat(i);
    if(document.getElementById(res).innerText == "Connect"){
        document.getElementById(res).click();}
    console.log(document.getElementById(res).innerText == "Connect");
    }
catch(err) {
}
}

```
There are a few illegal tokens in the code such as `‘,’,“,”` as well as the minus sign `—` which are not the ones used for parsing JavaScript. They should be replaced with `',',",",-`, respectively.

This problem usually happens when you copy text from a PDF or something which is not in pure text format.

```js
setInterval(function () {
 var x = $('.primary-action-button');
 for (var i = 0; i < x.length; i++){
  if(x[i].innerHTML == "Connect") {
   x[i].click()
  }
 }
 var y = $('a.page-link');
 y[y.length - 1].click();
}, 1000)
```