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

177
Views
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
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!