Quantcast
Viewing all articles
Browse latest Browse all 1607

Extension Requests • Re: Allow users to fully ignore/hide other users

I have these features implemented on my forum since mid-2023:

1. Global ignore: thread in Russian. It is basically a script running in the browser that hides all foes' replies (for some reason, phpBB does not do that out of the box).

Code:

<script>function removeAnnoyingQuotes(foes){    var count = 0;    for (var userInd = 0; userInd < foes.length; userInd ++) {        let userLink = "./memberlist.php?mode=viewprofile&u=" + foes[userInd][0]        var quoteNodes = document.evaluate(            "//a[@href='" + userLink + "']",            document,            null,            XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,            null);        for (var i = 0; i < quoteNodes.snapshotLength; i++) {            var authorElement = quoteNodes.snapshotItem(i);            let p1 = authorElement.parentElement;            if (p1 && p1.nodeName === "CITE") {                let p2 = p1.parentElement;                if (p2) {                    p2.innerHTML = blockedUserQuoteText(p2, foes[userInd][1]);                    count++;                 }            }        }    }    return count;}function removeAnnoyingFuzzyQuotes(foes){    var count = 0;    var quoteNodes = document.evaluate(        "//cite",        document,        null,        XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,        null);    for (var i = 0; i < quoteNodes.snapshotLength; i++) {        var el = quoteNodes.snapshotItem(i);        if (el.parentElement.nodeName === "DIV" && el.parentElement.parentElement.nodeName === "BLOCKQUOTE") {            var title = el.textContent            for (var userInd = 0; userInd < foes.length; userInd ++) {                if (title.startsWith(foes[userInd][1] + " ")) {                    var foeBlock = el.parentElement;                    foeBlock.innerHTML = blockedUserQuoteText(foeBlock, foes[userInd][1]);                    count++;                    break;                }            }        }    }    return count;}var ignoreQuoteId = 0;function blockedUserQuoteText(parent, foeName) {  ignoreQuoteId = ignoreQuoteId + 1;  var result = '<div id="quote_hidden' + ignoreQuoteId +  '">The author of <a class="display_hidden_quote" data-quote-id="' + ignoreQuoteId + '" href="./viewtopic.php">message</a> является <b>' + foeName + '</b>, is in your foe list.</div><div id="quote_content' + ignoreQuoteId + '" style="display: none;">' + parent.innerHTML + '</div>';  return result;}(function() {    'use strict';    var xhttp = new XMLHttpRequest();    xhttp.onreadystatechange = function() {         if (this.readyState == 4 && this.status == 200) {             let text = this.responseText;             let ind1 = text.indexOf("<select name=\"usernames[]\"");             if (ind1 != -1) {                 let optSearch = "<option value=\"";                 let ind2 = text.indexOf("</select>", ind1);                 let foeBlob = text.substring(ind1, ind2);                 // console.log("FOE " + foeBlob);                 var ind = 0;                 var foes = Array();                 while (true) {                     ind = foeBlob.indexOf(optSearch, ind);                     if (ind == -1) {                         break;                     }                     var endIdInd = foeBlob.indexOf("\">", ind);                     var foeId = foeBlob.substring(ind + optSearch.length, endIdInd);                     var endNameInd = foeBlob.indexOf("</option>", endIdInd)                     var foeName = foeBlob.substring(endIdInd + 2, endNameInd);                     foes.push([foeId, foeName]);                     ind = endNameInd;                 }                 if (foes.length > 0) {                     var count = removeAnnoyingQuotes(foes);                     count = count + removeAnnoyingFuzzyQuotes(foes);                      if(count) {                         $('.display_hidden_quote').on('click', function(e) {                        e.preventDefault();                      var quoteId = $(this).attr('data-quote-id');                      $('#quote_content' + quoteId).show();                        $('#quote_hidden' + quoteId).hide();                       });                     }                 }             }         }    };    // workaround to get list of foes -- we fetch the entire page and parse it to get a list of foes    xhttp.open("GET", "/ucp.php?i=ucp_zebra&mode=foes", true);    xhttp.send();})();</script>
I added above script to /styles/prosilver/template/viewtopic_body.html

2. Hide Foe Topics v1.0.0 https://github.com/privet-fun/phpbb_hidefoetopics

I was contemplating combining both into a single plugin but never got around to doing that.

BTW it's still not an optimal solution as in my experience it's not that easy to completely cut a foe out from the topic conversation thread.
This is because of the "flat" structure of phpBB topics/threas where a user can quote multiple people in one post.
Ideally you would want to hide replies from other users to the post made by a foe (perhaps this could be an option) but it's not that simple since a user can quote multiple people in a post.
In a tree-like conversation structure like the ones on Twitter you can simply cut a foe's reply and all the replies linked downwards.
That extension is actually exactly what I was looking for. Thank you so much. I think my users will be happy with just that. If there are further complaints about quoted replies, etc, I may look into your other suggestions but I think this will be a great start. Thanks again!

Statistics: Posted by tahiti — Mon Feb 03, 2025 7:13 pm



Viewing all articles
Browse latest Browse all 1607

Trending Articles