J
J
JSent2018-01-17 16:30:34
JavaScript
JSent, 2018-01-17 16:30:34

How to use userscript to replace the script on the page?

There was a need to replace the script on someone else's site. I am using tampermonkey.
Tried similar

document.getElementsByTagName("script")[0].innerHTML = newScript;

Did not work out.
I also tried to change the name of the function at the call site to refer to my script, but it's still not clear how to add my script to the page.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Bhudh, 2018-01-17
@Bhudh

What exactly didn't work for you? If you make the original script stop working, it’s natural, it is interpreted when the page is loaded, written to memory and works from there, so you can rewrite it at least a hundred times in the page code, it’s neither hot nor cold.
And your script is already added to the page, in the sense that the code called from Tampermonkey does not need to be written anywhere in the script tag on the page. It will work anyway, the main thing is that some work should take place in the script itself.
What exactly do you need to replace, write. What actions.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question