Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

529
Visualizações
In Chrome-Extension getting CORB error on injecting external script

I am creating a Chrome-extension and I want to inject a Javascript file in DOM from content.js file , But after injecting JS file I am getting Cross-Origin Read Blocking (CORB) blocked cross-origin response https://raw.githubusercontent.com/avinashiitb/bookmark-preview/main/injectScript.js

The idea behind to inject injectScript.js is to write a custom event in DOM and pass that event to content.js script

Manifest.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",
       "*://*/*"  
   ]
}

Content.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');

injectScript.js

alert("Hi");
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

  1. Download the script from the remote URL into your extension directory.
  2. Rename it to inject-script.js
  3. Run it as shown in method 1 here:
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 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda