Skip to content

[NodeBB] Focus Mode : simply immersive reading for NodeBB

Customisation
1 1 62
  • 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 : F to toggle. Ctrl+F, Cmd+F and Alt+F are 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 scrollBy so you stay exactly where you were.

    Topic-only : the button is greyed out on non-topic pages with a tooltip explaining why. Pressing F outside 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. Uses try/catch so 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 (getBoundingClientRectscrollBy) with no setTimeout on 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).

  • DownPWundefined DownPW marked this topic as a regular topic

Related Topics
  • Custom Page - nodebb

    Solved Customisation custom-pages nodebb
    13
    2
    5 Votes
    13 Posts
    937 Views
    I’m happy to see this
  • Custom badges

    Solved Customisation nodebb
    103
    2
    49 Votes
    103 Posts
    30k Views
    Perfect
  • Top Ranked Forums

    Chitchat nodebb top ranked
    9
    1
    3 Votes
    9 Posts
    2k Views
    The real issue here is that most people consider forums to be “dead” in the sense that nobody uses them anymore, and social media groups have taken their place. Their once dominant stance in the 90’s and early 00’s will never be experienced again, but having said that, there are a number of forums that did in fact survive the social media onslaught, and still enjoy a large user base. Forums tend to be niche. One that immediately sticks out is Reddit - despite looking like it was designed in the 80s, it still has an enormous user base. Another is Stack Overflow, which needs no introduction. The key to any forum is the content it offers, and the more people whom contribute in terms of posting , the more popular and widely respected it becomes as a reliable source of information. Forums are still intensely popular with gamers, alongside those that offer tips on hacking etc.
  • Changing Background on NodeBB

    Solved Customisation background image nodebb
    4
    0 Votes
    4 Posts
    1k Views
    @cagatay You’d target the body tag and use the below line of CSS background: url(/assets/customcss/backgrounds/default/default.png) no-repeat center center fixed; Obviously, you need to change the path to suit where your image is being stored. More info around the background property can be found here https://www.w3schools.com/cssref/css3_pr_background.php
  • [NODEBB] Scroll Button

    Solved Customisation css javascript html scroll button
    7
    1
    0 Votes
    7 Posts
    2k Views
    @downpw ooops. Forgot that. Thanks for adding.
  • Social icon (Nodebb)

    Solved Customisation nodebb social
    7
    0 Votes
    7 Posts
    2k Views
    @phenomlab said in Social icon (Nodebb): @jac I just tested my theory around using the OG image, and according to the Twitter card validator, it works fine [image: 1638880098289-73e805e1-997b-41bf-9259-51c5052ca8fc-image.png] fixed
  • NodeBB Discord Plugins

    Unsolved Customisation nodebb discord plugin
    7
    0 Votes
    7 Posts
    2k Views
    @RiekMedia hi. Just following up on this thread (I know it’s old) but was curious to understand if it’s still an issue or not ?
  • NodeBB customisation

    Locked Customisation
    332
    27 Votes
    332 Posts
    148k Views
    @jac Given your departure away from your previous project, I’m going to close this thread…