Dark / Light Mode Automatic Toggle Switch / jsdmat

Beta Dark / Light Mode Automatic Toggle Switch / jsdmat 0.4.0

No permission to download
Q: Will jsdmat work with {XYZ}?
A: There is no known dependency on other addons or styles besides the need of 2 enabled styles in minimum. Calling any style is done with XenForo built-in mechanisms, so as long as the native XenForo style environment is able to accept a style change by URI /misc/style?style_id=2&..., jsdmat can do the same.

Q: Does jsdmat use cookies?
A: No, it relies on a local storage dataset. A good explanation can be found here: https://xenforo.com/community/threads/cookie-purposes.186563/post-1469808

Q: Why do redirects land at top of page and do not jump back to post {XY} far, far down the page?
A: Afaik it seems not every browser (engine) is willing to deliver the anchor component of an URI to JS and/or to keep it up and alive during redirect calls. Known: Webkit/iOS unfortunately messed up keeping anchors during tests.

Q: Is there a way to use jsdmat without uploading files?
A: Yes, you can replace the conditional <xf:if is="$xf.fullJs">(...)</xf:if> in the invocation code with a direct embed: <script> content of file jsdmat.min.js </script>.
Be aware: You miss the opportunity to get the JS file cached at CDN / client side as designed by XenForo: Direct embed dumps additional 2.0 kB load to every single page delivery!

Q: How can I check why jsdmat is not working properly?
A: The non-minified JS contains several browser console output calls, which can help to get a clue what is going on. Non-minified JS is active in debug/dev mode of XF; or, in production environment, you may directly replace/exchange the JS files accordingly.

Q: jsdmat drives me mad during dev works, can I disable it just for me without code modifications?
A: Yes, please check the browser's local storage entries for {prefix}jsdmat and change the first entry "disable" to true.

Q: After a manual style change, jsdmat automatically switches back to the mode corresponding to prefers-color-scheme browser setting. What's wrong?
A: If you manually change style and it keeps flipping back automatically to the prefers-color-scheme preset, then the manual change detection call, which is located in the template edit of style_chooser, probably isn't there/active (at least not in the chosen style). Please check, if the JS call embed in style_chooser is present and active.
B: If you use other additional style choosing elements, then you'll have to add the mentioned JS call into the additional choosing elements so jsdmat is able to catch such events properly.