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

149
Visualizações
"web_accessible_resources" works on one site but not another

So im getting the classic "Resources must be listed in the web_accessible_resources manifest key in order to be loaded by pages outside the extension." error in the console. The problem is that I believe it is actually properly listed, since it works everywhere, except this site for some reason: https://raw.githubusercontent.com/InventivetalentDev/minecraft-assets/1.18.2/assets/minecraft/textures/block/dirt.png

Here are the relating parts of my files (I am using manifest v3):

manifest.json

    "web_accessible_resources": [
        {
          "resources": ["content.css", "sprite.svg"],
          "matches": ["<all_urls>"]
        }
    ],
    "content_scripts":
    [{
          "matches": ["<all_urls>"],
          "js": ["content-script.js"],
          "run_at": "document_start"
    }]

content-script.js

function injectCSS() {
  const link = newElement('link');
  const head = $('head');
  link.rel = 'stylesheet';
  link.type = "text/css"
  link.href = chrome.runtime.getURL('content.css');
  head.appendChild(link);
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

So, for anyone findig this question while looking for a solution for this problem in the future:

The reason this happens is that this site has a strict content policy, disallowing all resources (e.g. image or stylesheet) coming outside itself. There is 2 ways to solve this issue:

1. Easy and quick solution

  • Use this method only if you want to load a stylesheet (.css) every time, and only on the few specified websites in manifest.json!

manifest.json

"content_scripts":[
 {
   "js": ["content-script.js"],
   "css": ["style.css"],
   "matches": ["https://stackoverflow.com/*"]
 }
 ]

2. A hacky workaround I've learned from scripts

  • This method allows you to inject stylesheets without specifying anything in the manifest.json
  • For images, use BASE64 encoding. For SVGs, create them dinamically through JS.

content-script.js

window.addEventListener('load', function() {
   injectCSS();
})

function injectCSS() {
  const style = document.createElement('style');
  const head = document.querySelector('head');
  style.rel = 'stylesheet';
  style.type = "text/css"
  style.textContent = css;
  head.appendChild(style);
}


const css = `
::-webkit-scrollbar { 
  display: none;
}
`
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