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

222
Views
Javascript Image reference error from chrome extension service worker

I'm trying to make my own chrome extension for the first time that would capture your active tab as an image and then crop it. As you can see in the code below I used the chrome.tabs.captureVisibleTab() to get the tab as an dataURL. After that I want to convert the dataURL to an Image Object, but the service worker is responding with an Reference Error: Image is not defined. I'm just confused as to why its not valid? I am using manifest V3, so the script is running as a service worker in the background.

chrome.action.onClicked.addListener(getCurrentTab);

function getCurrentTab(){
    let capture = chrome.tabs.captureVisibleTab(null, {}, function(dataUrl){
        var img=new Image();
        img.src=dataUrl;
    });
}

And my manifest.json below if you want to take a look at that

{
    "name": "Screen to Text",
    "description": "Copies text in selected area to clipboard",
    "version": "1.0",
    "manifest_version": 3,
    "action": {
        "select": {
            "default_title": "Copy to clipboard",
            "default_icon": "icons/copy.png"
        }
    },
    "permissions": ["activeTab", "scripting"],
    "background": {
        "service_worker": "background.js"
    }
 }
about 4 years ago · Santiago Trujillo
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!