I'm trying to make an extension that collecting social networks links from the web page where user is. So when user clicking button getLinks
we get all links and then by checking condition passing them in the blocks of the extension. I tried to use chrome.tabs.executeScript
, and get links through urls = $$('a');
but it's not working
$('#getLinks').click(function(e)
{
var allLinks = [];
var i = 0;
chrome.tabs.executeScript( null, {"code": "urls = $$('a'); for (url in urls)
{ allLinks[i]=urls[url].href; i++;}"}, function() {
var vk;
var facebook;
var linkedin;
for (var i=0; i<allLinks.length; i++)
{
var profil = (allLinks[i].href);
if(profil.indexOf('vk.com')!=-1)
{
vk = profil;
$('#vk').text(vk);
}
if(profilito.indexOf('facebook.com')!=-1)
{
facebook = profil;
$('#fb').text(facebook);
}
if(profilito.indexOf('linkedin.com')!=-1)
{
linkedin = profil;
$('#linkin').text(linkedin);
}
}
});
});