Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

127
Visualizações
I'm trying to capture JavaScript from the clipboard and execute in to run on a webpage in Chrome

I have JavaScript that works when ran as a Bookmarklet. So, I know the code works.

However, I'm trying to avoid having to paste the bookmarklet to the bookmarks bar every time the code changes. The code changes on every document that we create, from our MIS system.

I want to be able to execute the JavaScript from the clipboard. Here's how I'm trying to do this:

javascript: window.focus();setTimeout(async () => {
  const text = await navigator.clipboard.readText();
  console.log(text);eval(text);
}, 2000);

It seems simple, get the text from the clipboard, then run it.

I know the text is being captured from the clipboard, because it is showing up on the console log.

What am I doing wrong?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I won't go into how I feel this is a spectacularly bad idea from a security perspective. I'm not aware of your environment so perhaps you have some means to ensure no malicious code ends up in the clipboard.

Perhaps CSP is blocking eval. If so you'll need to add the "unsafe-eval" value to the CSP. Are there any console log errors?

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda