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

285
Vistas
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 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