Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

107
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!