Last active
June 27, 2025 10:21
-
-
Save sefgit/37b88c903e23e56d68bf9303d6fb0ce7 to your computer and use it in GitHub Desktop.
auto scroll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<style> | |
html { | |
background-color: black; | |
color:darkgray; | |
overflow: hidden; | |
} | |
#logger { | |
padding-top:20px; | |
height:100%; | |
width:100%; | |
overflow-y: auto; | |
overflow-wrap: break-word; | |
scrollbar-color: darkgray transparent; | |
scrollbar-width: thin; | |
word-break:break-all; | |
white-space:pre-wrap; | |
} | |
</style> | |
</head> | |
<body> | |
<xmp id=logger></xmp> | |
<script> | |
const _log=console.log | |
let _logger = document.querySelector("#logger"); | |
console.log=function(...args){ | |
if (!_logger) return; | |
_logger._last = _logger._last || 0; | |
let _auto = (_logger._last <= _logger.scrollHeight); | |
let _pos = _logger.scrollTop + _logger.clientHeight; | |
if (_auto && _pos != _logger.scrollHeight) _auto = false; | |
_logger.innerText += `\n/${_auto?1:0}/${_logger._last}/${_logger.scrollHeight}/${_logger.scrollTop}/${args}`; | |
if (_auto) {_logger.scrollTo(0, _logger.scrollHeight);} | |
_logger._last = _logger.scrollHeight; | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment