[GH-ISSUE #46] Disable console clearing #27

Closed
opened 2026-03-01 14:33:58 +03:00 by kerem · 11 comments
Owner

Originally created by @Valar353 on GitHub (Aug 16, 2022).
Original GitHub issue: https://github.com/AEPKILL/devtools-detector/issues/46

Hey! Is it possible to disable console clearing?

Originally created by @Valar353 on GitHub (Aug 16, 2022). Original GitHub issue: https://github.com/AEPKILL/devtools-detector/issues/46 Hey! Is it possible to disable console clearing?
kerem 2026-03-01 14:33:58 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@RVFET commented on GitHub (Aug 16, 2022):

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

<!-- gh-comment-id:1216443913 --> @RVFET commented on GitHub (Aug 16, 2022): You can overwrite ```console.clear()``` method, however it'll be still possible to use Browser's built-in "Clear console" button.
Author
Owner

@AEPKILL commented on GitHub (Aug 18, 2022):

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() }
<!-- gh-comment-id:1219261700 --> @AEPKILL commented on GitHub (Aug 18, 2022): 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.: ```ts // __DEV__ may be injected by webpack or other bundle tools if (!__DEV__) { devtoolsDetector.launch() } ```
Author
Owner

@Valar353 commented on GitHub (Aug 22, 2022):

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?

<!-- gh-comment-id:1222385207 --> @Valar353 commented on GitHub (Aug 22, 2022): 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?
Author
Owner

@AEPKILL commented on GitHub (Sep 7, 2022):

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

<!-- gh-comment-id:1239479266 --> @AEPKILL commented on GitHub (Sep 7, 2022): I just tried it won't clear the console before call the `launch` method
Author
Owner

@jdempcy commented on GitHub (Sep 30, 2022):

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?

<!-- gh-comment-id:1263959812 --> @jdempcy commented on GitHub (Sep 30, 2022): 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?
Author
Owner

@AEPKILL commented on GitHub (Oct 29, 2022):

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

<!-- gh-comment-id:1295742941 --> @AEPKILL commented on GitHub (Oct 29, 2022): > 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. ```ts devtoolsDetector.launch = () => void const reader = require("@d-i-t-a/reader") ```
Author
Owner

@jdempcy commented on GitHub (Nov 18, 2022):

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

<!-- gh-comment-id:1320515713 --> @jdempcy commented on GitHub (Nov 18, 2022): 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 :)
Author
Owner

@jdempcy commented on GitHub (Nov 18, 2022):

Hey! Is it possible to disable console clearing?

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

<!-- gh-comment-id:1320516317 --> @jdempcy commented on GitHub (Nov 18, 2022): > Hey! Is it possible to disable console clearing? @Valar353 You can do this by overriding console.clear().
Author
Owner

@jdempcy commented on GitHub (Nov 18, 2022):

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

<!-- gh-comment-id:1320516652 --> @jdempcy commented on GitHub (Nov 18, 2022): @AEPKILL this question can be closed as there is a suitable workaround (imo)
Author
Owner

@jdempcy commented on GitHub (Nov 18, 2022):

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

<!-- gh-comment-id:1320532795 --> @jdempcy commented on GitHub (Nov 18, 2022): Note that pointing to void did not work for me and I actually had to override to an empty function with () => {}.
Author
Owner

@jfaylon commented on GitHub (Jul 21, 2025):

I'm trying to override the console.clear but to no avail. Is there a way to disable the logs for this module instead of clearing as this affects globally?

<!-- gh-comment-id:3095786163 --> @jfaylon commented on GitHub (Jul 21, 2025): I'm trying to override the console.clear but to no avail. Is there a way to disable the logs for this module instead of clearing as this affects globally?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/devtools-detector#27
No description provided.