Skip to content

Instantly share code, notes, and snippets.

@benqy
Forked from hiwanz/detect-console.html
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benqy/ae1683b07640d0b214fe to your computer and use it in GitHub Desktop.
Save benqy/ae1683b07640d0b214fe to your computer and use it in GitHub Desktop.
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>console track</title>
</head>
<body>
console status: <span id="stat"></span>
<script>
function isConsoleOpen() {
var el = document.createElement('div');
var ret = false;
el.__defineGetter__('id', function() {ret = true});
console.log(el);
console.clear();
return ret;
}
// test
setInterval(function() {
stat.innerHTML = isConsoleOpen() ? 'open' : 'closed';
}, 1000);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment