geekhack

geekhack Community => Off Topic => Topic started by: Coreda on Mon, 06 April 2020, 11:30:41

Title: geekhack Super Ignore™ userscript - hide users even while logged out
Post by: Coreda on Mon, 06 April 2020, 11:30:41
Something simple I slapped together recently. Entirely hides posts by specified users and optionally threads/topics created by them as well both on the board index pages and the Spy page.

Just needs one to manually add users by their user ID number (seen in the URL of their username link) in the script itself.

To install and configure:


Reload a page on geekhack and bask in nothingness :p

Note: doesn't hide quoted posts. I thought about it but the way it currently hides posts entirely it might make some replies seem non-sensical/out of context. Perhaps it would work if semi-hidden in a quote to indicate/toggle an ignored post. Also would have hosted on Github but having an issue with it atm.

Userscript:

More
Code: [Select]
// ==UserScript==
// @name         geekhack.org - Super Ignore
// @namespace    Coreda
// @version      2020-04-05
// @description  Hide user posts and optionally topics on geekhack even while logged out.
// @author       Coreda
// @license      MIT
// @match        https://geekhack.org/index.php?topic=*
// @match        https://geekhack.org/index.php?PHPSESSID=*&topic=*
// @match        https://geekhack.org/index.php?board=*
// @match        https://geekhack.org/index.php?action=recenttopics*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var hideThreads = true;

    function qsa(sel, parent){ return Array.prototype.slice.call((parent || document).querySelectorAll(sel)); }

    var ignoredUsers = [].concat(
         qsa("a[href$='u=11111']"), // Example ID only
         qsa("a[href$='u=22222']") // Example ID only
        )

    // Marginally less pre-hide flash than using a remove function
    function hide(elem) {
        elem.style.display = "none";
        }

    ignoredUsers.forEach(function(entry) {
        // Check if page is forum post
        if (window.location.href.indexOf("topic=") > -1) {
            var parent = entry.parentNode.parentNode.parentNode.parentNode;
            if (parent.classList.contains("windowbg") || parent.classList.contains("windowbg2")) {
                hide(parent);
                }
            }
        // Check if page is topic index
        if (hideThreads == true && window.location.href.indexOf("board=") > -1) {
            var parent = entry.parentNode.parentNode.parentNode.parentNode;
            if (parent.nodeName.toLowerCase() == "tr") {
                hide(parent);
                }
            }
        // Check if page is Spy
        if (hideThreads == true && window.location.href.indexOf("action=recenttopics") > -1) {
            var parent = entry.parentNode.parentNode;
            // Checks if username is contained in last table cell (to distinguish OP vs last poster)
            if(!entry.parentNode.nextElementSibling) {
                hide(parent);
                }
            }
    });

})();
Title: Re: geekhack Super Ignore™ userscript - hide users even while logged out
Post by: tp4tissue on Mon, 06 April 2020, 11:56:30
GH is prettty dead 99% of the time.

What would be the point of this, the post rate in general is so slow.
The only active section has been the shopping section.

LOL, if you got personal beef with Tp4,  just say it..
Title: Re: geekhack Super Ignore™ userscript - hide users even while logged out
Post by: Coreda on Mon, 06 April 2020, 12:08:51
What would be the point of this, the post rate in general is so slow.

I only use it for one user since their non sequiturs in virtually every topic became a bit annoying. Not naming names though  :D

LOL, if you got personal beef with Tp4,  just say it..

Not at all. tp keeps non IC/GB geekhack alive  ^-^
Title: Re: geekhack Super Ignore™ userscript - hide users even while logged out
Post by: tp4tissue on Mon, 06 April 2020, 12:16:05
What would be the point of this, the post rate in general is so slow.

I only use it for one user since their non sequiturs in virtually every topic became a bit annoying. Not naming names though  :D

LOL, if you got personal beef with Tp4,  just say it..

Not at all. tp keeps non IC/GB geekhack alive  ^-^

Glad Tp4 can count on your support in the upcoming cleansing. <covid is almost sure to shake up the establishment>

Stay safe y'all
Title: Re: geekhack Super Ignore™ userscript - hide users even while logged out
Post by: Coreda on Mon, 06 April 2020, 12:28:26
Glad Tp4 can count on your support in the upcoming cleansing.

Replaced the default examples with quasi-dummy values instead  :thumb:
Title: Re: geekhack Super Ignore™ userscript - hide users even while logged out
Post by: Coreda on Mon, 06 April 2020, 12:29:01
Oops double post.