[GUIDE] Hiding PRSI (and More) From Latest Replies [Desktop Only]

AngerDanger

macrumors 601
Original poster
Dec 9, 2008
4,633
20,943
Given the influx of threads complaining about the PRSI, ShinyDren's excellent post about hiding the PRSI (and other sub-fora) from the Latest Reply sidebar has received a surprising lack of attention, so I'm reiterating it here.

The scripts below grabs the list of forums you've ignored when you visit the Forums You Ignore page, and then it hides every reply that falls under corresponding thread-node-numbers from the sidebar.

You'll need a browser extension that can run user scripts, like TamperMonkey. Paste the following code into a new user script, click save, and view the Forums You Ignore page so it can grab the list. Thanks, @ShinyDren! :)

Code:
// ==UserScript==
// @name         MacRumors - Hide Ignored Forums in Latest Replies in Sidebar
// @namespace    mr.ShinyDren
// @version      0.3
// @description  Hide posts in Latest Replies in sidebar if they are in a node being ignored via site account settings.
// @author       ShinyDren
// @match        https://forums.macrumors.com/
// @match        https://forums.macrumors.com/account/ignored-forums
// @grant        none
// ==/UserScript==

// localStorage is assumed

var ignoredNodeRegex = /-47$/i; // fallback value
var numHidden = 0;

function copyIgnoredToLocalstorage() {
    if ( localStorage.getItem("_mod_sd_siteIgnoreForums") === null ) { // See if the localStorage item exists, display info message if not (only show message once).
        alert("Congratulations, it appears this is the first time running this script on the \"Forums You Ignore\" settings page.\n\nAny forums you select to ignore here will also be used to hide posts in the sidebar on the front page of the forums.");
    }
    var regexList = '';
    var checkedItems = document.querySelectorAll("ul.ignoredNodeList li input:checked"); // Get all matches.
    for (i = 0; i < checkedItems.length; i++) {
        var myValue = checkedItems[i].getAttribute("value");
        if ( i > 0 ) {
            regexList = regexList + "|";
        }
        regexList = regexList + "-" + myValue + "$";
    }
    localStorage.setItem("_mod_sd_siteIgnoreForums", regexList);
}

function checkReplies() { // Called once at page load.
    var theReplies = document.querySelectorAll(".sidebar .widget .avatarList li"); // Get all matches.
    if ( localStorage.getItem("_mod_sd_siteIgnoreForums") !== null ) { // If the ignoreForums value has been set use it instead of the fallback value.
        ignoredNodeRegex = new RegExp(localStorage.getItem("_mod_sd_siteIgnoreForums"), 'i');
    }
    for (i = 0; i < theReplies.length; i++) {
        if ( ignoredNodeRegex.test(theReplies[i].classList.item(1)) ) { // Contains the text.
            theReplies[i].style.display = "none"; // Hide the reply.
            numHidden++;
        }
    }
    if ( numHidden > 0 ) {
        var myNode = document.createElement("LI");
        var myTextnode = document.createTextNode(numHidden + " replies hidden per your request");
        myNode.appendChild(myTextnode);
        myNode.className = "userTitle"; // match other text
        myNode.style.padding = "10px 0 0 15px"; // adjust spacing
        theReplies[1].parentNode.appendChild(myNode);
    }
}

var myLoc = location.pathname;
//alert(myLoc); // for testing
if ( myLoc == "/account/ignored-forums" ) { // Get ignored items from page
    copyIgnoredToLocalstorage();
}

if ( myLoc == "/" ) { // Check/Hide replies
    checkReplies();
}
EDIT: Below, I've added the ability to also hide your ignored forums from the main list of forums, so right now, I don't even see a PRSI below the Site and Forum Feedback forum. Probably not the most useful addition for most, but I'm also using a stylesheet that makes Xenforo's list of forums look more like VBulletin used to.

Code:
// ==UserScript==
// @name         MacRumors - Hide Ignored Forums AND Their Latest Replies
// @namespace    mr.ShinyDren
// @version      0.31
// @description  Hide posts in Latest Replies in sidebar if they are in a node being ignored via site account settings.
// @author       ShinyDren & Danger
// @match        https://forums.macrumors.com/
// @match        https://forums.macrumors.com/account/ignored-forums
// @grant        none
// ==/UserScript==

// localStorage is assumed

var ignoredNodeRegex = /47$/i; // fallback value
var numHidden = 0;

function copyIgnoredToLocalstorage() {
    if ( localStorage.getItem("_mod_sd_siteIgnoreForums") === null ) { // See if the localStorage item exists, display info message if not (only show message once).
        alert("Congratulations, it appears this is the first time running this script on the \"Forums You Ignore\" settings page.\n\nAny forums you select to ignore here will also be used to hide posts in the sidebar on the front page of the forums.");
    }
    var regexList = '';
    var checkedItems = document.querySelectorAll("ul.ignoredNodeList li input:checked"); // Get all matches.
    for (i = 0; i < checkedItems.length; i++) {
        var myValue = checkedItems[i].getAttribute("value");
        if ( i > 0 ) {
            regexList = regexList + "|";
        }
        regexList = regexList + myValue + "$";
    }
    localStorage.setItem("_mod_sd_siteIgnoreForums", regexList);
}

function checkReplies() { // Called once at page load.
    var theReplies = document.querySelectorAll(".sidebar .widget .avatarList li"); // Get all matches.
    var theForums = document.querySelectorAll(".level_2");
    if ( localStorage.getItem("_mod_sd_siteIgnoreForums") !== null ) { // If the ignoreForums value has been set use it instead of the fallback value.
        ignoredNodeRegex = new RegExp(localStorage.getItem("_mod_sd_siteIgnoreForums"), 'i');
    }
    for (i = 0; i < theForums.length; i++) {
        //console.log(theReplies[i].classList.item(3));
        if ( ignoredNodeRegex.test(theForums[i].classList.item(3)) ) { // Contains the text.
            theForums[i].style.display = "none"; // Hide the forum.
        }
    }
    for (i = 0; i < theReplies.length; i++) {
        //console.log(theReplies[i].classList.item(3));
        if ( ignoredNodeRegex.test(theReplies[i].classList.item(1)) ) { // Contains the text.
            theReplies[i].style.display = "none"; // Hide the reply.
            numHidden++;
        }
    }
    if ( numHidden > 0 ) {
        var myNode = document.createElement("LI");
        var myTextnode = document.createTextNode(numHidden + " replies hidden per your request");
        myNode.appendChild(myTextnode);
        myNode.className = "userTitle"; // match other text
        myNode.style.padding = "10px 0 0 15px"; // adjust spacing
        theReplies[1].parentNode.appendChild(myNode);
    }
}

var myLoc = location.pathname;
//alert(myLoc); // for testing
if ( myLoc == "/account/ignored-forums" ) { // Get ignored items from page
    copyIgnoredToLocalstorage();
}

if ( myLoc == "/" ) { // Check/Hide replies
    checkReplies();
}
 
Last edited:

ShinyDren

macrumors member
Jun 25, 2010
67
23
Ambitoysterous, USA
EDIT: I've added the ability to also hide your ignored forums from the main list of forums, so right now, I don't even see a PRSI below the Site and Forum Feedback forum. Probably not the most useful addition for most, but I'm also using a stylesheet that makes Xenforo's list of forums look more like VBulletin used to.

// ==UserScript==
// @name MacRumors - Hide Ignored Forums AND Their Latest Replies
// @namespace mr.ShinyDren
// @Version 0.31
// @description Hide posts in Latest Replies in sidebar if they are in a node being ignored via site account settings.
// @author ShinyDren & Danger
// @match https://forums.macrumors.com/
// @match https://forums.macrumors.com/account/ignored-forums
// @Grant none
// ==/UserScript==

// localStorage is assumed

var ignoredNodeRegex = /47$/i; // fallback value
var numHidden = 0;

function copyIgnoredToLocalstorage() {
if ( localStorage.getItem("_mod_sd_siteIgnoreForums") === null ) { // See if the localStorage item exists, display info message if not (only show message once).
alert("Congratulations, it appears this is the first time running this script on the \"Forums You Ignore\" settings page.\n\nAny forums you select to ignore here will also be used to hide posts in the sidebar on the front page of the forums.");
}
var regexList = '';
var checkedItems = document.querySelectorAll("ul.ignoredNodeList li input:checked"); // Get all matches.
for (i = 0; i < checkedItems.length; i++) {
var myValue = checkedItems.getAttribute("value");
if ( i > 0 ) {
regexList = regexList + "|";
}
regexList = regexList + myValue + "$";
}
localStorage.setItem("_mod_sd_siteIgnoreForums", regexList);
}

function checkReplies() { // Called once at page load.
var theReplies = document.querySelectorAll(".sidebar .widget .avatarList li"); // Get all matches.
var theForums = document.querySelectorAll(".level_2");
if ( localStorage.getItem("_mod_sd_siteIgnoreForums") !== null ) { // If the ignoreForums value has been set use it instead of the fallback value.
ignoredNodeRegex = new RegExp(localStorage.getItem("_mod_sd_siteIgnoreForums"), 'i');
}
for (i = 0; i < theForums.length; i++) {
//console.log(theReplies.classList.item(3));
if ( ignoredNodeRegex.test(theForums.classList.item(3)) ) { // Contains the text.
theForums.style.display = "none"; // Hide the forum.
}
}
for (i = 0; i < theReplies.length; i++) {
//console.log(theReplies.classList.item(3));
if ( ignoredNodeRegex.test(theReplies.classList.item(1)) ) { // Contains the text.
theReplies.style.display = "none"; // Hide the reply.
numHidden++;
}
}
if ( numHidden > 0 ) {
var myNode = document.createElement("LI");
var myTextnode = document.createTextNode(numHidden + " replies hidden per your request");
myNode.appendChild(myTextnode);
myNode.className = "userTitle"; // match other text
myNode.style.padding = "10px 0 0 15px"; // adjust spacing
theReplies[1].parentNode.appendChild(myNode);
}
}

var myLoc = location.pathname;
//alert(myLoc); // for testing
if ( myLoc == "/account/ignored-forums" ) { // Get ignored items from page
copyIgnoredToLocalstorage();
}

if ( myLoc == "/" ) { // Check/Hide replies
checkReplies();
}
Nice addition to include it on the main forum list.
 
  • Like
Reactions: AngerDanger

AngerDanger

macrumors 601
Original poster
Dec 9, 2008
4,633
20,943
When I paste the new script into TM, I get a few errors and it won't save.

A few lines like this:
View attachment 804775
That's really odd; the part of the script giving an error is the same between both the new and old versions. I always get the same error, but both still run for me. Anyway, I threw a couple of vars before the implicit global variables to narrow their scope and pasted the change into the OP.
 

SandboxGeneral

Moderator emeritus
Sep 8, 2010
26,080
9,275
Detroit
That's really odd; the part of the script giving an error is the same between both the new and old versions. I always get the same error, but both still run for me. Anyway, I threw a couple of vars before the implicit global variables to narrow their scope and pasted the change into the OP.
Odd indeed. This one is on the MBA and still own't work. No errors like earlier, but when I try to save it, it says invalid user script.

Yesterday I did this on the Mac mini and it worked just fine. Both on Safari with only TM and LastPass installed.

Edit: Well, I went to the Mac mini and found in TM utilities that I can backup scripts to Google Drive and I did that with my two MacRumors scripts. Then I went back to the MacBook Air and imported the scripts from my Google Drive and now its working.

Weird. But at least it succeeded.
 
Last edited:

ericgtr12

macrumors 65816
Mar 19, 2015
1,288
7,882
It would be nice if we also had an option to hide ignored users as well. As it stands you can still see their avatar and what they've done both in the sidebar and last post by columns.
 

chown33

Moderator
Staff member
Aug 9, 2009
8,733
5,068
vertical
Hahaha, I just realized what you and @SandboxGeneral were getting; I might just be a little bit of an idiot.

I originally posted the script inside a spoiler tag, so forums.macrumors when through and changed all of the @s into username mentions!

Alright, fixed. Lemme know if it works.
Yes, CODE tags are important.

Another typical programming expression is [i] which is also the BBCode for "start italic".

If you're wondering how I got that to appear without starting italics, there's another BBCode for "not BBCode" which is [plain].
 
  • Like
Reactions: AngerDanger

maflynn

Moderator
Staff member
May 3, 2009
66,404
33,055
Boston
Awesome. Also, would you mind telling me what user script editor you're using? It looks like it runs on iOS, and if so, I'd love to give it a try myself.
I just used what you recommended - tampermonkey. It was that which gave me the error in my attempt to save the script.
 
  • Like
Reactions: AngerDanger

Similar threads

Register on MacRumors! This sidebar will go away, and you'll see fewer ads.