[NodeBB] Focus Mode : simply immersive reading for NodeBB
-
Hey everyone,
I’m not sure where to post this, I’ll let @phenomlab edit it if necessary.
Already posted here : https://community.nodebb.org/topic/19318/focus-mode-simply-immersive-reading-for-nodebb
I’ve been working on a small client-side script that adds an simply immersive reading mode to NodeBB. No plugin required, just a few lines of custom JS and CSS dropped into the ACP.
I’m just sharing this here for fun : https://github.com/DroidBV8/nodebb-focus-mode

What it does
Pressing F (or clicking the icon in the right sidebar) hides everything that isn’t the content you’re trying to read:
- Both sidebars
- Header / brand bar
- Footer
- Topic thumbnails and sidebar tools (reply, follow, timeline)
The content area reflows to a centered 860px column, font size bumps up slightly, and a reading progress bar appears at the top of the page.
To exit: press F again, Escape, or click the floating button that appears in the bottom-right corner.
Details
Activation effect : a subtle CRT glitch effect plays on toggle. Three CSS variables let you dial the intensity up or down without touching the keyframes:
--fm-glitch-opacity: 1; /* 0.5 = subtle | 2 = heavy */ --fm-glitch-skew: 1deg; --fm-glitch-shift: 4px;Keyboard :
Fto toggle.Ctrl+F,Cmd+FandAlt+Fare ignored so you don’t accidentally trigger it when searching the page.Scroll preservation : when toggling, the layout shifts because sidebars appear/disappear. The script measures the position of the nearest visible post before and after the layout change, then compensates with
scrollByso you stay exactly where you were.Topic-only : the button is greyed out on non-topic pages with a tooltip explaining why. Pressing
Foutside a topic shows a small toast instead of doing nothing silently.Mobile: disabled entirely under 768px. No button injected, no state restored.
Theming : all colors reference Bootstrap CSS variables (
--bs-body-bg,--bs-border-color,--bs-primary, etc.) so it adapts automatically to any NodeBB theme, light or dark.State : saved in
localStorage, restored on next visit. Usestry/catchso it degrades gracefully in private browsing.
Implementation notes
The script is a self-contained IIFE, hooking into the standard NodeBB client-side events:
$(window).on('action:ajaxify.end', function () { focusMode(); }); $(window).on('action:topic.loaded', function () { focusMode(); }); // etc.The glitch effect is pure CSS
@keyframes, the JS only adds/removes classes. Layout compensation is synchronous (getBoundingClientRect→scrollBy) with nosetTimeouton the scroll itself, which avoids triggering NodeBB’s scroll-based URL updater in a loop.
Compatibility
Tested on NodeBB 3.x with Bootstrap 5 themes. Should work on any setup using the standard sidebar components (
nav.sidebar-left,nav.sidebar-right). -
undefined DownPW marked this topic as a regular topic
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register LoginRelated Topics
-
-
-
-
-
-
-
NodeBB Discord Plugins
Unsolved Customisation -