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

206
Vistas
Chrome extension: execute something in JS console

I build an extension (my pet project) where I click on name of snippet and it will automatically add it to console. I'm stuck because when I use console.log my snippets is already "entered" and after invoking that function it shows reference error: enter image description here

The point is - how to write something into a console using event to "paste snippet" without hitting enter?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You'll want to eval the output you're logging as well (but that can be very dangerous with uncontrolled input).

For example:

const testFunctionText = `var test = () => console.log(1)`

console.log(testFunctionText)
eval(testFunctionText)

document.getElementById("run").onclick = () => {
    eval(document.getElementById("input").value)
}
<input id="input" placeholder="Evaluate console statement (no input on StackOverflow)">
<button id="run">Run</button>

With this code snippet, try putting test() into the provided input.

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