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

287
Visualizações
Uncaught TypeError: Cannot read properties of undefined (reading 'sync')

In my injected content script, I'm attempting to use the chrome storage api:

content.js

document.addEventListener("paste", (event) => {
        let paste = event.clipboardData.getData('text');
        var lookalike = isLikeWallet(paste)
        if (lookalike) {
            chrome.storage.sync.get("wallets", (items) => {
                var wallets = items.wallets;
                if(!wallets.includes(paste)) {
                    alert('alert')
                }
            });
        }
});

It worked the last time I tested it - a few days ago. Now I get the error:

Uncaught TypeError: Cannot read properties of undefined (reading 'sync')
    at HTMLDocument.<anonymous> (contentScript.js:10)

This storage API seems to be the accepted method for accessing shared state variables across your background, popup, and content scripts, and the documentation states: (https://developer.chrome.com/docs/extensions/reference/storage/)

Your extension's content scripts can directly access user data without the need for a background page.

I.e. I don't need to use the messaging API to send data back and forth.

Here's my manifest.json:

{
    "name": "Test extension",
    "description": "Description",
    "version": "1.0",
    "manifest_version": 3,
    "background": {
        "service_worker": "background.js"
      },
      "permissions": ["storage", "activeTab"],
      "action": {
        "default_popup": "popup.html",
        "default_icon": {
            "16": "/images/test16.png",
            "32": "/images/test32.png",
            "48": "/images/test48.png",
            "128": "/images/test128.png"
          }
      },
      "icons": {
        "16": "/images/test16.png",
        "32": "/images/test32.png",
        "48": "/images/test48.png",
        "128": "/images/test128.png"
      },
      "content_scripts": [
        {
          "matches": ["<all_urls>"],
          "js": ["contentScript.js"]
        }
      ]
  }

Thank you in advance for any help! Not sure what's going on here - especially since it worked (and reliably) just a few days ago.

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