You can also detect it from CSS, here is one thing I added as a theme-component to the Dark Theme here in Meta:
@media all and (display-mode: standalone) {
//blink-based browsers (don't work on safari, which exposes a JS only API for this)
::-webkit-scrollbar {
background: $secondary;
}
::-webkit-scrollbar-thumb {
background: $header_primary-medium;
}
::-webkit-scrollbar-corner {
background: $secondary;
}
//firefox
body {
scrollbar-color: $header_primary-medium $secondary;
}
}