0

I would like to modify a piece of javascript that gets loaded by a webpage before that code actually is executed. I know where the line of code I want to modify is, and I can use the browser debugger to set a breakpoint just before that line, however, once the execution is paused I'm unable to modify the script code.

Does anyone know how to achieve this?

PS: Please note that all the rest of the script can remain identical to the original, and I don't want to block all javascript execution, just change a single (or a few) line before my browser runs it.

ClonedOne
  • 569
  • 4
  • 20
  • Are you changing it permanently or temporarily? – Algo7 Apr 21 '20 at 16:04
  • @AvivLo temporarily I suppose? I don't have control over the server that is providing me the script, so I am only interested in local changes in the browser in the current "loading" of the page. – ClonedOne Apr 22 '20 at 04:06
  • You will probably have to write another script that changes the script that you want to modify before you actually load it. This is just a theory. – Algo7 Apr 22 '20 at 11:37

1 Answers1

1

This is tantamount to override, and there is already a question that answer that

Override Javascript file in chrome

Personally I would go with the local override option as described here

ParthianShotgun
  • 602
  • 4
  • 20
  • Interesting, I hoped there would be an easier, and less browser-specific solution, but this is a good start. Thank you! – ClonedOne Apr 22 '20 at 04:10