Trying to make an etsy chrome extension. I have a console.log() but it is not showing up in the console of the extension

84 Views Asked by At

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

}

1

There are 1 best solutions below

10
superabsorbent polymer On

The question is which console?

  • If you have logs in your content script, logs go to injected page's dev console.

  • If you have logs in your background script, they go to the service worker console that you can open from the extension's page in chrome://extensions

  • If you have a popup page, logs go to the service worker console.