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

131
Views
asíncrono en chrome.webRequest.onBeforeRequest?

¿Es posible trabajar con async/await en webRequest.onBeforeRequest de la API de Chrome?

Lo siguiente funciona; De "trabajar" quiero decir que bloquea/cancela la solicitud como esperaba.

 chrome.webRequest.onBeforeRequest.addListener( function (details) { console.log("URL intercepted:", {url: details.url, type: details.type,}); let match = details.url.match(/:\/\/(www\.)?someSiteThatIWantAvoidRawIp\.org(\/)?$/); // you are accessing this url on your chorme if (match) { console.log("URL blocked:", { url: details.url, type: details.type, match: match, }); return { cancel: true }; } }, { urls: [ "<all_urls>" ], types: ["main_frame",] }, ["blocking",] );

Sin embargo, lo siguiente no funciona; Se supone que debe bloquear/cancelar la solicitud después de esperar, pero la cancelación no funciona pero la página aparece sin un error de conexión.

 chrome.webRequest.onBeforeRequest.addListener( async function (details) { console.log("URL intercepted:", {url: details.url, type: details.type,}); let match = details.url.match(/:\/\/(www\.)?someSiteThatIWantAvoidRawIp\.org(\/)?$/); let ip = await axios.get('https://someSiteThatChecksMyIp.org', {}) // this gets my ip .then(r => { console.log(r); return r.data; }) .catch(e => { console.log(e); }); if (match) { if (ip == "123.123.123.123") // assume my raw ip { console.log("URL blocked:", { url: details.url, type: details.type, match: match, }); return { cancel: true }; } } }, { urls: [ "<all_urls>" ], types: ["main_frame",] }, ["blocking",] );

¿Qué es incorrecto con mi configuración? Gracias.

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!