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

267
Visualizações
How can I get JSON data from a browser extension (Chrome) from another server?

I am writing a browser extension that should periodically receive the exchange rate in the JSON format and place it in local storage. But when I try to do this in the code of a page of any site, I get error:

Access to XMLHttpRequest at 'https://my.server.domain/currency.txt' from origin 'https://developer.mozilla.org' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Sample request code

$updateUrl = "hhttps://my.server.domain/currency.txt";
$.get($updateUrl).done(function($updData) {

});

The only place where I can run a script like this is in popup.html, but I need updates to be triggered automatically. I tried to do it through Background but in manifest v3 there is no such possibility anymore.

The only option is to periodically open the update.html extension page and perform updates in it, but this happens by opening a new tab, and I would like to do this in the background.

Any tips?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

In general, I wrote this in background.js and it works

fetch("https://my.server.domain/currency.txt")
.then((response) => {
    return response.json();
})
.then((data) => {
    console.log(data);
});

It remains now to figure out how to make the script periodically update the data, otherwise it works only once. But that is another story.

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