[GH-ISSUE #6] Mac FireFox上的表现有点问题 #90

Closed
opened 2026-03-01 17:27:29 +03:00 by kerem · 2 comments
Owner

Originally created by @JnathanCoder on GitHub (Jun 27, 2019).
Original GitHub issue: https://github.com/AEPKILL/devtools-detector/issues/6

  • 机器:Mac
  • 浏览器:Firefox
  • 问题描述:第一次打开的时候,显示close。然后关闭控制台,状态变为open,之后又变成close
Originally created by @JnathanCoder on GitHub (Jun 27, 2019). Original GitHub issue: https://github.com/AEPKILL/devtools-detector/issues/6 - 机器:Mac - 浏览器:Firefox - 问题描述:第一次打开的时候,显示close。然后关闭控制台,状态变为open,之后又变成close
kerem closed this issue 2026-03-01 17:27:29 +03:00
Author
Owner

@AEPKILL commented on GitHub (Jun 30, 2019):

检测控制台是否打开的的原理是在浏览器中执行 console.log 时,打开控制台和关闭控制台的行为略有差异。
但是在火狐浏览器下打开控制台但是不切换到 Console 面板下的时候,console.log 输出的内容并不会真正的被输出。
所以常规的常规的 console.log 的做法在 Firefox 打开控制台但没有切换到 Console 面板下的时候 就失效了
为了规避这种情况,判断控制台是否打开又增加了这样一段逻辑:

const start = performance.now();
debugger;
const isOpen = now() - startTime > 100;

这段逻辑不会即时反应控制台的打开状态,但是会在关闭控制台的瞬间显示曾经打开过控制台,而且会影响他人做代码调试,所以我把它作为替代方案,也就出现了你描述的情况。

如果有更优雅的方法,Pull request welcome.

<!-- gh-comment-id:507004509 --> @AEPKILL commented on GitHub (Jun 30, 2019): 检测控制台是否打开的的原理是在浏览器中执行 `console.log` 时,打开控制台和关闭控制台的行为略有差异。 但是在火狐浏览器下打开控制台但是不切换到 `Console` 面板下的时候,`console.log` 输出的内容并不会真正的被输出。 所以常规的常规的 `console.log` 的做法在 `Firefox` **打开控制台但没有切换到 `Console` 面板下的时候** 就失效了 为了规避这种情况,判断控制台是否打开又增加了这样一段逻辑: ```typescript const start = performance.now(); debugger; const isOpen = now() - startTime > 100; ``` 这段逻辑不会即时反应控制台的打开状态,但是会在关闭控制台的瞬间显示曾经打开过控制台,而且会影响他人做代码调试,所以我把它作为替代方案,也就出现了你描述的情况。 如果有更优雅的方法,Pull request welcome.
Author
Owner

@JnathanCoder commented on GitHub (Jul 2, 2019):

好的 感谢回复。------------------ 原始邮件 ------------------
发件人: "AEPKILL"notifications@github.com
发送时间: 2019年6月30日(星期天) 中午11:35
收件人: "AEPKILL/devtools-detector"devtools-detector@noreply.github.com;
抄送: "JnathanCoder"949204575@qq.com;"Author"author@noreply.github.com;
主题: Re: [AEPKILL/devtools-detector] Mac FireFox上的表现有点问题 (#6)

检测控制台是否打开的的原理是在浏览器中执行 console.log 时,打开控制台和关闭控制台的行为略有差异。
但是在火狐浏览器下打开控制台但是不切换到 Console 面板下的时候,console.log 输出的内容并不会真正的被输出。
所以常规的常规的 console.log 的做法在 Firefox 打开控制台但没有切换到 Console 面板下的时候 就失效了
为了规避这种情况,判断控制台是否打开又增加了这样一段逻辑:
const start = performance.now(); debugger; const isOpen = now() - startTime > 100;

这段逻辑不会即时反应控制台的打开状态,但是会在关闭控制台的瞬间显示曾经打开过控制台,而且会影响他人做代码调试,所以我把它作为替代方案,也就出现了你描述的情况。

如果有更优雅的方法,Pull request welcome.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

<!-- gh-comment-id:507603961 --> @JnathanCoder commented on GitHub (Jul 2, 2019): 好的 感谢回复。------------------ 原始邮件 ------------------ 发件人: "AEPKILL"<notifications@github.com> 发送时间: 2019年6月30日(星期天) 中午11:35 收件人: "AEPKILL/devtools-detector"<devtools-detector@noreply.github.com>; 抄送: "JnathanCoder"<949204575@qq.com>;"Author"<author@noreply.github.com>; 主题: Re: [AEPKILL/devtools-detector] Mac FireFox上的表现有点问题 (#6) 检测控制台是否打开的的原理是在浏览器中执行 console.log 时,打开控制台和关闭控制台的行为略有差异。 但是在火狐浏览器下打开控制台但是不切换到 Console 面板下的时候,console.log 输出的内容并不会真正的被输出。 所以常规的常规的 console.log 的做法在 Firefox 打开控制台但没有切换到 Console 面板下的时候 就失效了 为了规避这种情况,判断控制台是否打开又增加了这样一段逻辑: const start = performance.now(); debugger; const isOpen = now() - startTime > 100; 这段逻辑不会即时反应控制台的打开状态,但是会在关闭控制台的瞬间显示曾经打开过控制台,而且会影响他人做代码调试,所以我把它作为替代方案,也就出现了你描述的情况。 如果有更优雅的方法,Pull request welcome. &mdash; You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
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#90
No description provided.