How to use 'link jquery google' in JavaScript

Every line of 'link jquery google' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
2function searchGoogle(searchTerm, func) {
3 var link = "https://www.google.com/search?q=" + searchTerm;
4 var promise = util.ajaxPromise(link);
5 function handleLink(link) {
6 if (link) {
7 var id = background.util().getParameterByName("v", link);
8 if (id && id != "") {
9 func(true, id);
10 return true;
11 }
12 }
13 return false;
14 }
15 promise.then(function (result) {
16 var doc = util.getDocFromHTML(result),
17 mainLink = doc.find(".twQ0Be a"),
18 links = doc.find("cite.iUh30"),
19 link;
20 if (mainLink.length > 0) {
21 link = mainLink.attr('href');
22 if (handleLink(link)) {
23 return;
24 }
25 }
26 if (links.length > 0) {
27 for (var i = 0; i < links.length; i++) {
28 link = $(links[i]).html();
29 if (handleLink(link)) {
30 return;
31 }
32 }
33 }
34 func(false);
35 }).catch(function (error) {
36 func(false, error);
37 });
38}

Related snippets