Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

180
Vistas
Chrome.storage.sync usage before page starts to add DOM elements

I am making an extension for university site, which i have no back-end access to. The task is to reorganize certain block elements, for which im trying to store information about in the string with numbers (elements are added into this string after the page loads). It worked well with localStorage, but ultimately there was a problem - each time the site admins update the site, the cache get cleared and the data is lost, so i choose to move to chrome.storage API.

Now, here is the problem. The behavior of chrome.storage.sync.get is rather incosistent, it might be slow enough to not get any data in the cache in time for MutationObserver to start working. I understand chrome.storage.sync.get is a asynchronous callback, but have no way to force it to work before the page starts getting filled.

window.toDelete = [];

chrome.storage.sync.get('course', function(entries){
    window.toDelete = deserializeEntries(entries.course);
    console.log("hello");
})

// Mutation observer declaration and .observe call

In this example it might go either way, "hello" being printed before or after MutationObserver does all the work. I have a call that prints the contents of toDelete in MutationObserver to tell if it works with properly filled cache or not. Example 1 Example 2

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda