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

468
Views
Uncaught SyntaxError: Invalid or unexpected token (Chrome Extension)

I'm basically trying to create an extension that finds and replaces a single image, but the background script keeps coming up with a SyntaxError no matter how much I fiddle with it.

Screenshot of error that comes up

I'm following this tutorial for the most part, except I'm looking to replace a single image instead of multiple. I have pasted the code I have so far with specific details redacted:

manifest.json

{
"manifest_version" : 2,
"name" : "Test",
"version" : "0.1",
"description" : "test",
"web_accessible_resources" : [
"*.png"
],
"icons" : {
"128": "test.png"
},
"background" : {
"scripts" : ["bgp.js"]
},
"browser_action" : {
"default_icon" : "test.png"
},
"content_scripts" : [
{
"matches" : [
"https://test.com/, https://test.com/*"
],
"js" : ["content.js"]
}
]
} 

bgp.js

console.log(“Background running”);
chrome.browserAction.onClicked.addListener(buttonClicked);
function buttonClicked(tab)
{
let msg = {
txt : “Hello”
}
chrome.tabs.sendMessage(tab.id,msg);
}
}

content.js (adding for the sake of completion)

console.log('replacing image');
chrome.runtime.onMessage.addListener(replace);

function replace()
{

let imgs = document.querySelector(".example");

let url = chrome.extension.getURL("test.png");


   img.src = url;
console.log(url);

}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You're using the wrong quotation marks in your background script. You're using ” but you should use " or '.

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