Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript: document.write function have redefined, how can I recover it

Tags:

javascript

When I visit some website(such as: https://www.baidu.com) and open browser dev tool, I found they have redefined function "document.write" as:

document.write
//output: ƒ (){}

yes, they have replaced "document.write" with a "blank" function.
So my question is: how can I recover "document.write" to original function?

like image 671
user10274697 Avatar asked Mar 26 '26 05:03

user10274697


1 Answers

As per baidu javascript code document.write is rewritten with empty function. In code it's written as document.write = document.writeln = function() {}

document is instance of Document, we can assign Document.prototype.write to document.write it'll update function to its default. Below is the sample code snippet to override function to use it's default standard document.write = Document.prototype.write

like image 168
nerding_it Avatar answered Mar 27 '26 17:03

nerding_it



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!