I am working on a Chrome extension that will save the URL link of the active tab when a user clicks on the extension icon. The goal is to store this URL in local storage and keep it saved until the active window is closed. I have set up an array called tablink
to hold these URLs.
Below is the content of my manifest.json
:
{
"manifest_version": 2,
"name": "saveLink",
"version": "1.0",
"browser_action": {
"default_icon": "xyz.png",
"default_popup": "popup.html",
"default_title": "saveLink"
},
"permissions": [
"activeTab",
"storage",
"tabs"
]
}
Additionally, here is the content of my popup.js
, which contains JavaScript code for the associated popup.html
:
var tablink = [];
function getTabUrl(){
chrome.tabs.getSelected(null,function(tab) {
var len = tablink.length;
if(len == 0){
tablink[0] = tab.url;
}
else {
tablink[len] = tab.url;
}
console.log(tablink);
}
}
document.addEventListener("DOMContentLoaded", function() {
getTabUrl();
link.addEventListener('click', function() {
chrome.tabs.update({url: 'https://www.google.com/'});
});
});
Currently, I am facing issues as the console is not printing anything. Additionally, the extension's button, which should redirect to google.com, no longer works after adding the code to save tab links. Any guidance on potential solutions would be greatly appreciated.