Pregunta

if you have an extension with multiple content scripts injected into a single page, is it possible to address a specific content script on the page rather than broadcasting to all content scripts? Thanks!

¿Fue útil?

Solución

If I understand you correctly, you could execute your content scripts in your background.js instead of defining it in your manifest.json:

if (condition) {
  chrome.tabs.executeScript(null, { file: 'contentscript1.js' });
} else {
  chrome.tabs.executeScript(null, { file: 'contentscript2.js' });
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top