0

The following is my code

document.getElementById('randomname').onclick = () => {
  chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
    chrome.scripting.executeScript({
      target: {tabId: tabs[0].id},
      function: randomName
    });
  });
}  

function randomName() {
    // Your script goes here
    var name = extern.generateRandomName()
    alert(name);
   
}

My issue is that when this code is run, because it is not defined in my js file, it says it is not defined. BUT, this function extern.generateRandomName() is defined on the website this code is running on.

  • Sounds like this just runtime scripting of content scripts, if thats the case then they work in isolated worlds (https://developer.chrome.com/docs/extensions/mv3/content_scripts/#isolated_world) – r0bb077 Jan 04 '23 at 06:07

0 Answers0