• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

437
Views
En Chrome-Extension, se obtiene un error CORB al inyectar un script externo

Estoy creando una extensión de Chrome y quiero inyectar un archivo Javascript en DOM desde el archivo content.js, pero después de inyectar el archivo JS, Cross-Origin Read Blocking (CORB) blocked cross-origin response https://raw.githubusercontent.com/avinashiitb/bookmark-preview/main/injectScript.js

La idea detrás de inyectar injectScript.js es escribir un evento personalizado en DOM y pasar ese evento al script content.js

Manifiesto.Json

 { "manifest_version": 2, "name": "Preview & Bookmark", "author": "Aviansh", "version": "0.001", "content_scripts": [ { "matches": ["*://*/*"], "js": [ "content.js" ], "css": [ "style.css" ] } ], "background": { "scripts": [ "background.js" ] }, "web_accessible_resources": [ "inject-script.js" ], "browser_action": {}, "permissions": [ "storage", "*://*/*" ] }

Contenido.js

 function injectScript(file_path, tag) { var node = document.getElementsByTagName(tag)[0]; var script = document.createElement('script'); script.setAttribute('type', 'text/javascript'); script.setAttribute('src', file_path); node.appendChild(script); } injectScript("https://raw.githubusercontent.com/avinashiitb/bookmark-preview/main/injectScript.js", 'body');

inyectarScript.js

 alert("Hi");
about 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

  1. Descargue el script desde la URL remota a su directorio de extensiones.
  2. Cámbiele el nombre a inject-script.js
  3. Ejecútelo como se muestra en el método 1 aquí :
 var s = document.createElement('script'); s.src = chrome.runtime.getURL('inject-script.js'); s.onload = function() { this.remove(); }; (document.head || document.documentElement).appendChild(s);
about 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error