0

//the html is below

     <button id="tab-el">SAVE TAB</button>

//the javascript is below

tabEl.addEventListener("click", function(){  
    chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
        myLeads.push(tabs[0].url)
        localStorage.setItem("myLeads", JSON.stringify(myLeads) )
        render(myLeads)
    })
})

//the JSON file is below


{
    "manifest_version": 3,
    "version": "1.0",
    "name": "Leads tracker",
    "action": {
        "default_popup": "index.html",
        "default_icon": "icon.png"
    },
        "permissions": [
          "tabs"
        ]
      
}

//the error my chrome console is showing is below

Script.js:51 Uncaught TypeError: Cannot read properties of undefined (reading 'query')
    at HTMLButtonElement.<anonymous> (Script.js:51:17)

//tired to grab links from websites to create a bookmark extension but so far not working

  • Did you open index.html directly from disk or from localhost? It won't work. Open it by clicking your extension icon. Note that this popup is a separate window so it has its own separate devtools: right-click inside the popup and select "inspect" in the menu. – wOxxOm Dec 28 '22 at 18:23
  • thank you so much for helping. yes i tried what u have suggested, – Abdullah Nazardeen Dec 29 '22 at 06:44
  • thank you so much for helping. yes i tried what u have suggested, when i try to grab the url using the extension it doent work. and the dev tools of the extension says,....Array(1) 0 : {active: true, audible: false, autoDiscardable: true, discarded: false, favIconUrl: '', …} length : 1 [[Prototype]] : Array(0) – Abdullah Nazardeen Dec 29 '22 at 06:54
  • Add "activeTab" to "permissions" and use [this answer](https://stackoverflow.com/a/63886442) – wOxxOm Dec 29 '22 at 09:37
  • Thank you a lot. My problem is solved. you were a great help. – Abdullah Nazardeen Dec 29 '22 at 10:00

0 Answers0