Hi!
If you’re like me and like opening unread topics in new tabs when you visit the forum but don’t want to click on each topic manually, I made a JavaScript
-snippet that can help do it automatically!
However, as there seems to be no way to programmatically control whether a link is opened in a new tab or window, this script will replicate what your preferred way of opening links is in your browser settings. You probably want to make sure your browser prefers tabs, as this script will open a maximum of 10
tabs at a time; you can vary this number by changing the MAX_INSTANCES
variable. You should be able to verify this by CTRL
/CMD
-clicking on any link; if the link is opened in a new tab, this script should also open your unread topics in tabs.
You activate this script by pasting it in the developer console of your browser when you’re in a section of the forum that displays unread topics (white links). The developer console can be accessed in various ways, but pressing F12
should work for pretty much all browsers. If the console isn’t displayed by default it can be accessed by selecting the tab named Console or similar.
Paste this script in the console, press Enter
, and it should open unread topics. If you want to repeat the action at a later stage, you can press the up arrow in the console to until you find the script and press Enter
again, or type openUnreadTopics()
if you haven’t closed the tab since you last run the script.
function openUnreadTopics() {
const MAX_INSTANCES = 10;
const unreadLinks = Array.from(
document.querySelectorAll(
"tr.topic-list-item:not(.visited) a.raw-topic-link"
)
);
if (unreadLinks.length === 0) console.log("No unread topics found!");
else {
const excess = unreadLinks.splice(MAX_INSTANCES);
console.log(
`Opening ${unreadLinks.length} unread topic${
unreadLinks.length > 1 ? "s" : ""
}...`
);
unreadLinks.forEach((link) => window.open(link.getAttribute("href")));
if (excess.length > 0)
console.log(
`${excess.length} additional unread topic${
excess.length > 1 ? "s" : ""
} currently remaining.`
);
}
}
openUnreadTopics();