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

97
Visualizações
How can I clear storage.sync for my chrome extension?

I have a small chrome extension I've built using chrome.storage.sync api to cache user-entered data. However, when the user runs a delete operation, the data persists in the storage area, even after I run sync.remove and sync.clear- is there something I'm missing?

                chrome.storage.sync.get('tasks', function(obj) {
                
                //assign tasks array to variable
                var tasks = obj.hasOwnProperty('tasks') ? obj.tasks : [];
                    chrome.storage.sync.remove('tasks': liValue);
                    chrome.storage.sync.clear();
                //find and remove deleted task from array, checking against cached li text value
                //liValue is cached textnode value prior to dom deletion
                for(var j = 0; j < tasks.length; j++) {
                    if(tasks[j] == liValue) {
                        tasks.splice(j, 1);
                        alert("splicing " + tasks[j] + "!!!");
                    }
                }
                //reset tasks in storage
                chrome.storage.sync.set({'tasks': tasks}, function() {
                    if (chrome.runtime.lastError)
                        console.log(chrome.runtime.lastError);
                    else
                        console.log("Tasks saved successfully");
                });

            });

I've looked thru the docs here and as best I can tell I'm using the method signatures correctly. Somebody described a similar issue in this SO post but applying the same code does not seem to be resolving my issue.

about 4 years ago · Juan Pablo Isaza
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