如何结合使用javascript代码与我的谷歌扩展程序一起使用

时间:2017-07-20 02:49:02

标签: javascript google-chrome-extension linkedin

我正在尝试使用Google扩展程序来保留我在Linkedin上已经看过的人的姓名

enter image description here

当我点击下一页或更改我试图获取Google扩展程序的页面时,请在此页面中显示此图片。

这是我的清单:

{
    "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' "
}

这些是我试图用来跟踪数据的函数:

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);

我正在尝试尝试,但它仍然无法正常工作。我真的是javascript和谷歌扩展的新手。请帮帮我:(

0 个答案:

没有答案