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

101
Visualizações
Chrome extension : webRequest.onHeadersReceived for take Headers

We are a group of students, and we are attempting to develop a web extension (chrome) for a project. We'd like to develop a web extension which measures the data usage of the Internet browser. To this goal, we want to take the header of a page to have files sizes.

We wanted to test if we could make an alert after receiving the headers.

We have make this test :

var callback = function(details) {
    console.log('Les Headers ont ete recus');
    alert("BBBBBBBBBBBBBBBBBBBBB");
}
var filter = { urls: 
    [
        '<all_urls>'
    ]
};
var opt_extraInfoSpec = [];

chrome.webRequest.onHeadersReceived.addListener(
    callback, filter, opt_extraInfoSpec
);

We also try this :

function callback() {
    console.log('Les Headers ont ete recus');
    alert("BBBBBBBBBBBBBBBBBBBBB");
}
var filter = { urls: 
    [
        '<all_urls>'
    ]
};
var opt_extraInfoSpec = ["requestHeaders"];

chrome.webRequest.onHeadersReceived.addListener(
    callback, filter, opt_extraInfoSpec
)

the manifest :

{

  "description": "truc écolo",
  "manifest_version": 2,
  "name": "PolNum",
  "version": "0.1",
  "icons": {
    "48": "icons/icon48.png"
  },
  


  "permissions": [
    "activeTab",
    "http://*/*",
    "https://*/*",
    "tabs", 
    "notifications",
    "webRequest",
    "*://*.google.com/",
    "storage"
  ],

"browser_action": {
    "default_popup" :"popup.html",
    "default_icon": {
      "16": "icons/icon16.png",
      "32": "icons/icon32.png"
    },
    "background": {
      "scripts": ["background.js"]
    }
  
    
  }

}

We are a beginner in Javascript

But we have a problem, we never see the alert and the console.log. Can we help us ?

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

0

manifest.json :

{

  "description": "truc écolo",
  "manifest_version": 2,
  "name": "PolNum",
  "version": "0.1",
  "icons": {
    "48": "icons/icon48.png"
  },
  
"permissions": [
  "webRequest",
  "activeTab",
  "http://*/*",
  "https://*/*",
  "tabs",
  "*://*.google.com/",
  "storage",
  "notifications" 
],

"browser_action": {
  "default_popup" :"popup.html",
  "default_icon": {
    "16": "icons/icon16.png",
    "32": "icons/icon32.png"
    }
  },

"background": {
  "scripts": ["background.js"]
  }  
}

background.js :

var callback = function(details) {
    console.log('Les Headers ont ete recus');
}
var filter = { urls: ['<all_urls>']
};
var opt_extraInfoSpec = ['responseHeaders'];

chrome.webRequest.onHeadersReceived.addListener(
    callback, filter, opt_extraInfoSpec
);
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