Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
Envío de un mensaje desde el fondo al script de contenido

Estoy tratando de enviar un mensaje simple desde backround.js a content-script.js pero no tengo mucho éxito.

aquí está el código relevante de fondo:

 function sendStop(){ chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { chrome.tabs.sendMessage(tabs[0].id, {greeting: "stop"}, function(response) { }); }); } theScriptsAreinserted = false chrome.contextMenus.onClicked.addListener(function(clickDate) { if (clickDate.menuItemId == 'select' && theScriptsAreinserted == false) { addJsScript() addCssScript() theScriptsAreinserted = true if (clickDate.menuItemId == 'select' && theScriptsAreinserted == true) { sendStop() } } });

y aquí está el código relevante del script de contenido (se ejecuta todo el tiempo):

 function reset(){ chrome.runtime.onMessage.addListener( function(request, sender, sendResponse) { console.log(sender.tab); if (request.greeting === "stop"){ finish == true; console.log("finish") } } ); }

Acabo de aprenderlo, así que espero no cometer un error terrible y hacerte perder el tiempo. Cualquier ayuda será apreciada :)

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!