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

114
Visualizações
How to get the amount of transferred data during a session with the help of an extension?

In a extension I am building, I need to get all the transfer data sizes of all website I am going to visit after clicking on a button. At the end, I will show to total amount of data transferred during one session of test.

Currently in the extension, when I press the button "start", it is going to call some functions from a background.js including adding some listeners. These listeners will be stopped when the user will click on "stop button.

Here is the function called by the listener inside the background file.

function getDataTransferredSize(){
  var sum = 0;
  if (window.performance === undefined) {
    console.log("= Display Size Data: performance NOT supported");
    return;
  }
  var list = window.performance.getEntriesByType("resource");
  if (list === undefined) {
    console.log("= Display Size Data: performance.getEntriesByType() is  NOT supported");
    return;
  }
  console.log("= Display Size Data");
  for (var i=0; i < list.length; i++) {
    if ("transferSize" in list[i]) {
      console.log("... transferSize[" + i + "] = " + list[i].transferSize);
      sum = sum + list[i].transferSize;
    }
    else
      console.log("... transferSize[" + i + "] = NOT supported");
  }
  totalDataTransferredSize += sum;
  console.log("Data transf : " + totalDataTransferredSize)
}

the problem is it does not sum up all the sizes of transferred data in each webpage where the extension is opened but it is doing it in the context of the extension. I could not manage to get the sizes outside the extension. Do you have any idea on how to do it ?

about 4 years ago · Juan Pablo Isaza
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