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

155
Views
Verificar si la pestaña ya está abierta para la extensión de Chrome y abrir una nueva pestaña en consecuencia

Estoy desarrollando un complemento y al presionar los botones en mi complemento se abren nuevas pestañas. Pero no quiero volver a abrir una pestaña ya abierta. Así que creé una función llamada openTab() . Pero esta función no funciona exactamente como quiero porque hago las comprobaciones con includes() . Por ejemplo, https://www.youtube.com está abierto en el navegador y cuando presiono el botón, https://www.youtube.com/watch?v=9I16FhnSa-c debería abrirse en una nueva pestaña. Pero la función openTab() dice que esta pestaña ya está abierta y actualiza la pestaña existente. ¿Cómo puedo resolver el problema?

JS

 function openTab(tabUrl, historyLabel, historyHostName) { var isTabActive = false; var tabId = 0; totalHistoryContent++; chrome.tabs.query({}, function(tabs) { for(var i=0;i<tabs.length;i++) { if(tabs[i].url.toLowerCase().includes(tabUrl.toLowerCase()) == true || tabUrl.toLowerCase().includes(tabs[i].url.toLowerCase()) == true) { isTabActive = true; tabId = tabs[i].id; break; } } if(isTabActive == false) { chrome.tabs.create({ url:tabUrl }); } else{ chrome.tabs.update(tabId, {selected: true}); chrome.tabs.reload(tabId); } }); try { if(tabUrl.includes("chrome-extension://" + chrome.runtime.id + "/popup.html") == false && tabUrl.includes("chrome://extensions/?id=" + chrome.runtime.id) == false) { setHistory(historyLabel, historyHostName); } } catch (error) {} }
about 4 years ago · Santiago Gelvez
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!