Closed Valar353 closed 10 months ago
You can overwrite console.clear()
method, however it'll be still possible to use Browser's built-in "Clear console" button.
If clear is disabled, a lot of information for detection will appear in the console (every detection loop) If you want the your debugging information not to cleared, you can turn off the detection in the development environment
E.g.:
// __DEV__ may be injected by webpack or other bundle tools
if (!__DEV__) { devtoolsDetector.launch() }
Got it, thanks for the reply. However, the library clears the console before I call the launch
method, is there any way to get around this?
I just tried it won't clear the console before call the launch
method
I am using a package which uses devtoolsDetector (@d-i-t-a/reader) and so I do not have control over devtoolsDetector.launch() nor do I see that anywhere in the reader code. Is there another way to configure devtools-detector not to clear the console?
I am using a package which uses devtoolsDetector (@d-i-t-a/reader) and so I do not have control over devtoolsDetector.launch() nor do I see that anywhere in the reader code. Is there another way to configure devtools-detector not to clear the console?
you can rewrite devtoolsDetector.launch
method before import @d-i-t-a/reader
e.g.
devtoolsDetector.launch = () => void
const reader = require("@d-i-t-a/reader")
This disables other functionality used by the module for its content protection which requires detecting when the dev tools are open. What I really need to do is disable the console clearing. I actually found a way to do this by just pointing console.clear to an empty function, ilke you did with the launch method. In the index.html for the whole React app I simply add a script like so:
<!-- Disable console.clear() for debugging purposes -->
<script type="text/javascript">console.clear = () => {};</script>
Thanks for the great tool! And for the good idea of overriding the method like that :)
Hey! Is it possible to disable console clearing?
@Valar353 You can do this by overriding console.clear().
@AEPKILL this question can be closed as there is a suitable workaround (imo)
Note that pointing to void did not work for me and I actually had to override to an empty function with () => {}.
Hey! Is it possible to disable console clearing?