How to inject content script in the specific url from other urls

28 Views Asked by At

I want to acheive such a that when I am on the other url still my content script should get injected into specific url. Is this possible?

currently I am using scripting api to inject the content script but it will inject the script within the specific url only

document
  .getElementById("injectButton")
  .addEventListener("click", async function () {
    const currentTab = await getCurrentTab();
    if (currentTab) {
      chrome.scripting.executeScript({
        target: { tabId: currentTab.id },
        files: ["content_script.js"],
      });
    } else {
      console.error("Unable to get the current tab.");
    }
  });

Not sure how to proceed

0

There are 0 best solutions below