devtools-detector icon indicating copy to clipboard operation
devtools-detector copied to clipboard

Disable console clearing

Open Valar353 opened this issue 2 years ago • 4 comments

Hey! Is it possible to disable console clearing?

Valar353 avatar Aug 16 '22 06:08 Valar353

You can overwrite console.clear() method, however it'll be still possible to use Browser's built-in "Clear console" button.

RVFET avatar Aug 16 '22 10:08 RVFET

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() }

AEPKILL avatar Aug 18 '22 09:08 AEPKILL

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?

Valar353 avatar Aug 22 '22 13:08 Valar353

I just tried it won't clear the console before call the launch method

AEPKILL avatar Sep 07 '22 14:09 AEPKILL

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?

jdempcy avatar Sep 30 '22 19:09 jdempcy

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")

AEPKILL avatar Oct 29 '22 05:10 AEPKILL

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 :)

jdempcy avatar Nov 18 '22 20:11 jdempcy

Hey! Is it possible to disable console clearing?

@Valar353 You can do this by overriding console.clear().

jdempcy avatar Nov 18 '22 20:11 jdempcy

@AEPKILL this question can be closed as there is a suitable workaround (imo)

jdempcy avatar Nov 18 '22 20:11 jdempcy

Note that pointing to void did not work for me and I actually had to override to an empty function with () => {}.

jdempcy avatar Nov 18 '22 21:11 jdempcy