Enhance Discourse forums with instant topic switching, current topic highlighting, and smart theme detection
目前為
A powerful user script that brings seamless topic navigation, intelligent current topic highlighting, and adaptive theme switching to Discourse forums. Browse your favorite forums with unprecedented speed and efficiency.
`)This script operates entirely on the client-side with a focus on efficiency and minimal resource usage:
Client-Side Caching: When you visit a topic list page, the script captures the HTML content of the topic list and stores it in your browser's local storage.
Zero Additional Server Requests: The script works with content that's already been loaded by your browser, creating no additional load on the Discourse server.
SPA Navigation: The script leverages Discourse's Single Page Application architecture to navigate between topics without full page reloads, making navigation nearly instantaneous.
DOM Manipulation: The cached topic list is displayed through careful DOM manipulation, creating a seamless overlay that matches your forum's current theme.
Event-Based Interaction: All user interactions (keyboard shortcuts, button clicks) are handled through efficient event listeners.
The design philosophy prioritizes performance and server friendliness - the script adds convenient navigation without generating any additional server requests beyond what Discourse normally requires.
Due to the caching mechanism used by the script, there are some limitations:
Non-Real-Time Data: The reply counts and view counts displayed in the cached topic list are not real-time data, but rather the data at the time of caching.
Cache Freshness: The topic list is only updated when you visit a list page. If you haven't visited a list page for a long time, the cached data may differ significantly from the actual situation.
New Topics Not Automatically Displayed: New topics posted after you cached the list won't appear in the quick switcher until you visit the list page again to refresh the cache.
Limited Topic Count: The quick switcher can only display topics included in the last list page you visited, typically one page worth of content.
These limitations are design choices made to maintain the script's lightweight nature and zero additional server request advantage.
Cache a Topic List:
View the Cached List:
`)Navigate Between Topics:
Close the Popup:
You can modify the following settings at the top of the script:
const CONFIG = {
// Keyboard shortcut (default: backtick key)
HOTKEY: '`',
// Cache key name
CACHE_KEY: 'discourse_topic_list_cache',
// Cache expiration time (in milliseconds) - 1 hour
CACHE_EXPIRY: 60 * 60 * 1000,
// Whether to show the floating button on topic pages
SHOW_FLOATING_BUTTON: true,
// Route check interval (in milliseconds)
ROUTE_CHECK_INTERVAL: 500,
// Whether to automatically follow system dark mode
AUTO_DARK_MODE: true,
}
This script is designed for all Discourse forums and has been tested on the following browsers:
MIT License - see the LICENSE file for details
Contributions are welcome! Please feel free to submit a pull request.