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

237
Visualizações
How to loop through each item in chrome.storage, when key values are unknown?

Is it possible for me to loop through every item stored using chrome.storage.sync.set? All the values stored have a URL and some CSS code, but the problem is, I don't know the URLs. I was thinking of something like this in my popup.js:

for (item in chrome.storage.sync.get()) {
    alert("Executed for ${url}")
    // How would I get url?
}

However, that never gets executed, even without the invalid variable.

How would I be able to do this?

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

0

All chrome API that return a Promise or can accept a callback are asynchronous.

ManifestV3: use await inside a function declared as async

async function enumStorage() {
  const all = await chrome.storage.sync.get();
  for (const [key, val] of Object.entries(all)) {
    // do something
  }
}

ManifestV2: use a callback

chrome.storage.sync.get(all => {
  for (const [key, val] of Object.entries(all)) {
    // do something
  }
});

Note that the popup is a separate window so it has its own separate devtools and console: right-click inside the popup and select "inspect" in the menu.

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