1

I am trying to use a google extension to keep name of people that I have already seen on Linkedin

enter image description here

Form this picture when I click the next page or change the page I am trying to get the google extension to keep the track of the name of person in this page.

This is my Manifest:

{
    "manifest_version": 2,
    "name": "One test",
    "description": "test.",
    "version": "1.0",
    "background": {"scripts": ["test.js"]},

     "page_action": 
    {
        "default_icon": "pic1.png"

    },

     "permissions": ["tabs"],

   "content_security_policy": "script-src 'self' https://www.jbhired.com; object-src 'self' "
}

And these are the functions I am trying to use to keep track of the data:

function check(tab_id, data, tab) {
    if (tab.url.indexOf('https://www.linkedin.com/search/results/people/') > -1) {
        chrome.pageAction.show(tab_id);
    }
};
chrome.tabs.onUpdated.addListener(check);


// _______________________________________________________________________






var data = (function(){
    return {
        bigArr: [],
    }
})();


var interfaceCtrl = (function() {
    var selector = document.querySelector('.page-list');



    return {
        selectTwo: selector.childNodes[1].childNodes[5],
        cons: document.querySelector('.nav-item__profile-member-photo').alt,
        nextClass: document.querySelector('.next'),
        selectOne: selector.childNodes[1].childNodes[2].classList.value
    }

})();


var listeners = (function(arr, ui){

    document.querySelector('.results-paginator').addEventListener('click',function(event){
    if(event.target.innerText === ui.selectTwo.innerText || ( event.target.classList.value === 'next-text' && ui.selectOne == 'active')) {
        arr.bigArr.push({
            consultant: ui.cons,
            search: window.location.href,
            time: Date.now()
        });
    }
    });
})(data,interfaceCtrl);

I am trying try but it's still not working. I'm really a newbie on both javascript and google extensions. help me please :(

Alexander Higgins
  • 6,101
  • 1
  • 16
  • 35
punchh
  • 491
  • 1
  • 4
  • 5
  • 1
    You need a content script, see https://stackoverflow.com/a/4532567 – wOxxOm Jul 20 '17 at 03:31
  • I suggest you read the [Chrome extension overview](https://developer.chrome.com/extensions/overview) (perhaps along with the pages linked from the overview). The [architecture section](https://developer.chrome.com/extensions/overview#arch) has overall architecture information which should help your understanding of how things are generally organized/done. You will probably also want to read [Content Scripts](https://developer.chrome.com/extensions/content_scripts). – Makyen Jul 20 '17 at 05:08
  • In general, you should try to use a different method of selecting the elements than `childNodes[n]`. Using that method tends to be quite vulnerable to breaking due to minor changes in the page. – Makyen Jul 20 '17 at 05:11

0 Answers0