I am trying to make an etsy chrome extension. I have a console.log() but it is not showing up in the console of the extension. I am trying to console.log the urlParameters below. When I open the console for the chrome extension that I made, it shows a blank console. I am not sure if the issue has to do with the host_permissions or permission. I don't have the etsy api. Here are the files I have:
background.js file:
chrome.tabs.onUpdated.addListener((tabId, tab) => {
if (tab.url && tab.url.includes("etsy.com/listing")) {
const queryParameters = tab.url.split("/")[4];
const urlParameters = new URLSearchParams(queryParameters);
console.log(urlParameters);
chrome.tabs.sendMessage(tabId, {
type: "NEW",
videoId: window.location.href.split("/")[4],
});
}
});
contentScript.js:
(() => {
let current_id = "";
chrome.runtime.onMessage.addListener((obj, sender, response) => {
const {type, value, videoId} = obj;
if(type === "NEW") {
current_id = videoId;
newIdLoaded();
}
});
})();
manifest.json
{
"name": "EZ Profit",
"version": "0.1.0",
"description": "Book keeping on ETSY",
"permissions": ["storage", "tabs"],
"host_permissions": ["https://*.etsy.com/*"],
"background": {
"service_worker": "background.js"
},
"content_scripts": [
{
"matches": ["https://*.etsy.com/*"],
"js": ["contentScript.js"]
}
],
"action": {
"default_icon": {
"16": "assets/ext-icon.png",
"24": "assets/ext-icon.png",
"32": "assets/ext-icon.png"
},
"default_title": "EZ Profits",
"default_popup": "popup.html"
},
"manifest_version": 3
}