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

156
Views
Extensión de Chrome: ¿Cómo uso declarativeNetRequest para eludir la Política de seguridad de contenido?

Estoy creando una extensión que inyecta un script proporcionado por el usuario en el sitio web actual. Ya terminé esa parte (con la ayuda de wOxxOm ). El único problema es que en algunos sitios web no funciona. Arroja este error en la consola: Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' . He estado tratando de solucionar esto usando declarativeNetRequest, sin embargo, no funciona.

regla1.json

 [ { "id": 1, "priority": 1, "action": { "type": "modifyHeaders", "responseHeaders": [ { "header": "content-security-policy", "operation": "remove" } ] }, "condition": { "urlFilter": "*://*/*", "resourceTypes": ["main_frame"] } } ]

manifiesto.json

 { ... "permissions": ["scripting", "activeTab", "declarativeNetRequest"], ... "declarative_net_request": { "rule_resources": [ { "id": "ruleset_1", "enabled": true, "path": "/rules/rule1.json" } ] } }

JavaScript

 let button = document.getElementById("run"); button.addEventListener("click", async () => { let input = document.getElementById("script"); let script = input.value; await execInPage(script); }); async function execInPage(code) { const [tab] = await chrome.tabs.query({ currentWindow: true, active: true }); chrome.scripting.executeScript({ target: { tabId: tab.id }, func: (code) => { const el = document.createElement("script"); el.textContent = code; document.head.appendChild(el); }, args: [code], world: "MAIN", }); }

Estoy usando manifiesto v3. La extensión aún no ha sido publicada. Estoy usando el modo desarrollador por ahora.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No parece funcionar en sitios web que usan el elemento para configurar CSP. ¿Alguien tiene otra solución?

about 4 years ago · Juan Pablo Isaza Report
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!