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

174
Visualizações
How do I make a content script load before another content script (that runs on the same event) in a Firefox extension?

Here's a portion of my manifest.json file:

  "content_scripts": [ {
"js": [ "common.js", "generation.js" ],
"matches": [ "*://www.site.com/*" ],
"run_at": "document_start"
},
{
"js": [ "page_init.js" ],
"matches": [ "*://www.site.com/*" ],
"run_at": "document_start"
},

Here, I want to run "common.js" before "page_init.js", as common.js contains much shared code and global variables and functions that the other content scripts need to function. I have defined common.js before page_init.js in my manifest, and, in Chrome, doing this results in common.js running before all the other content scripts, which is what I need. However, in Firefox, it doesn't seem to do this.

When I run this extension in Firefox, however, page_init throws an error:

ReferenceError: ReferenceError: href is not defined

"href" is a variable that's defined in common.js.

Do I need to make page_init.js run at document_end in order for common.js to fully run, or is there another way? I need them to both run at document_start.

UPDATE:

I managed to resolve the issue by changing the manifests contents to this:

 "content_scripts": [ 
{
"js": [ "common.js", "generation.js", "page_init.js" ],
"matches": [ "*://www.site.com/*" ],
"run_at": "document_start"
},
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

From firefox documentation:

js

An array of paths, relative to manifest.json, referencing JavaScript files that will be injected into matching pages.

Files are injected in the order given. This means that, for example, if you include jQuery here followed by another content script, like this...

It's probably a firefox bug, you may want to report it.

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