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

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