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

147
Visualizações
Un-overwrite a JavaScript function

I made UserScripts, and am now stuck.

Inside of my HTML there is a script tag, and inside the script tag there is the following:

<script>
   setTimeout = function(){}
</script>

There is no way to use the function, its useless.

How can I solve this?

I was thinking using a way to set the function like main = setTimeout() and I can reset it after the script is loaded. Back to like setTimeout = main.

I am also trying to stay (mostly) undetected unlike running all of the code in a different environment like an iframe. I know you can just use setInterval and then break the loop, but this is just an example.

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

0

Run your userscript before the page has a chance to overwrite it. Use // @run-at document-start in the metadata block (combined with instant script injection in the Advanced section of Tampermonkey's config), and then you could do, in your userscript:

const origSetTimeout = window.setTimeout;
// proceed with your script, referencing origSetTimeout

which will continue to work even after the page loads and has overwritten the original setTimeout. (While you could reassign window.setTimeout back to the original one later, that would be detectable - if that's really a concern.)

The variables declared in the userscript, even at the top level, will not leak out into the page scope, so don't worry about origSetTimeout being exposed - though other actions done in the userscript could be detected.

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