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

477
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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