Page 1 of 1

Foe Feature

Posted: Fri Feb 13, 2015 1:07 pm
by AWSchmit
Is that a way to make it so that you don't even know the people on your foe list even exists? I'll read through a thread and see, so and so has a message that we're hiding from you, but I'd rather not even know there's a post there I can't see.... I know this is kind of stupid, but just thought I'd check if that was possible. Thanks.

Re: Foe Feature

Posted: Wed Feb 18, 2015 1:20 pm
by luau
There's no easy configuration option I see that users or admins can twiddle to provide this behavior.

That doesn't mean the behavior you're after can't be achieved via other means though. 'Augmented browsing' is what you're after and, given the skills, it's not difficult to get what you want. It took me about 45 minutes total to whip up a decent solution for Firefox. I'm not sure it's something we really want to encourage, but I'll consult the other admins and see what they say.

Re: Foe Feature

Posted: Thu Feb 19, 2015 7:18 am
by luau
Okay, nobody cares so here's a nice foe scrubbing script.

You'll need to be using Firefox and you'll need to install the Greasemonkey extension. Or you could use Chrome or Safari but you'll have to read up on the details of running Greasemonkey scripts in them.

The script affects three pages:
index.php: If a listed foe has made the last post in any forum, their name and a link to their profile are tastefully edited so as to minimize the distress caused by their presence.
viewforum.php: The last post link in any topic will be edited as in index.php. Additionally, any topics begun by a foe will be completely hidden.
viewtopic.php: Any post made by a foe will completely hidden. Additionally, all quotes by foes will be completely hidden.

You'll need to edit the script to specify your foes. I've specified the two of us as foes as an example. It's pretty self-explanatory, but I know what I'm doing so don't hesitate to ask for assistance.

You'll need to install the script into Greasemonkey. Just copy it, save it as offsetguitars.user.js on your hard drive, and then install it by clicking the browser's File | Open File menu option and selecting it.

Code: Select all

// ==UserScript==
// @name        offsetguitars.com
// @namespace   offsetguitars.com
// @description offsetguitars.com
// @version     1
// @grant       none
// @include     /^http://www\.offsetguitars\.com/forums/index.*$/
// @include     /^http://www\.offsetguitars\.com/forums/viewforum.*$/
// @include     /^http://www\.offsetguitars\.com/forums/viewtopic.*$/
// ==/UserScript==

try {
    var bad_users = [{name: 'luau', number: '305'},
                     {name: 'AWSchmit', number: '2329'}]; 

    var bu;
    var elems;
    var e;

    for (bu = 0; bu < bad_users.length; ++bu) {
        if (window.location.href.indexOf('viewtopic') > 0) {
            // remove posts
            elems = document.querySelectorAll('p.author > strong > a[href$="' + bad_users[bu].number + '"]');
            for (e = 0; e < elems.length; ++e) {
                elems[e].parentNode.parentNode.parentNode.parentNode.parentNode.style.display = 'none';
            }
    
            // remove quotes
            elems = document.querySelectorAll('blockquote > div > cite');
            for (e = 0; e < elems.length; ++e) {
                if (elems[e].innerHTML.indexOf(bad_users[bu].name) === 0) {
                    elems[e].parentNode.parentNode.style.display = 'none';
                }
            }
        }
        else if (window.location.href.indexOf('viewforum') > 0) {
            // remove topics
            elems = document.querySelectorAll('li.row > dl.icon > dt > a[href$="' + bad_users[bu].number + '"]');
            for (e = 0; e < elems.length; ++e) {
                elems[e].parentNode.parentNode.parentNode.style.display = 'none';
            }
            
            // edit last post by link
            elems = document.querySelectorAll('dd.lastpost > span > a[href$="' + bad_users[bu].number + '"]');
            for (e = 0; e < elems.length; ++e) {
                elems[e].innerHTML = 'DIRTY FOE';
                elems[e].href = 'http://www.apa.org/topics/anger/control.aspx';
            }
        }
        else if (window.location.href.indexOf('index') > 0) {
            // edit last post by link
            elems = document.querySelectorAll('dd.lastpost > span > a[href$="' + bad_users[bu].number + '"]');
            for (e = 0; e < elems.length; ++e) {
                elems[e].innerHTML = 'DIRTY FOE';
                elems[e].href = 'http://www.apa.org/topics/anger/control.aspx';
            }
        }
    }    
}
catch (exception) {
    alert(exception);
}

Re: Foe Feature

Posted: Thu Feb 19, 2015 8:34 am
by mackerelmint
Nice!

Re: Foe Feature

Posted: Thu Feb 19, 2015 10:08 am
by mackerelmint
I just have a question about the "number" attached to the name:
try {
var bad_users = [{name: 'luau', number: '305'},
{name: 'AWSchmit', number: '2329'}];
Everything else is totally self-explanatory, but if every user has a unique number that the site uses to reference them, how are we supposed to find that? I'm assuming that this directs the browser to reference them with their unique number with respect to the site. If I'm way off, then what's that number and how does one determine the correct value for a foe?

Re: Foe Feature

Posted: Thu Feb 19, 2015 10:47 am
by mjet
mackerelmint wrote:
Everything else is totally self-explanatory, but if every user has a unique number that the site uses to reference them, how are we supposed to find that?
Right-click on a username under their avatar and a open the user's profile page. The number is there in the URL.

For instance: mackerelmint = 14037

http://www.offsetguitars.com/forums/mem ... le&u=14037

Re: Foe Feature

Posted: Thu Feb 19, 2015 11:23 am
by mackerelmint
mjet wrote:
mackerelmint wrote:
Everything else is totally self-explanatory, but if every user has a unique number that the site uses to reference them, how are we supposed to find that?
Right-click on a username under their avatar and a open the user's profile page. The number is there in the URL.

For instance: mackerelmint = 14037

http://www.offsetguitars.com/forums/mem ... le&u=14037
Aha, thanks!

Re: Foe Feature

Posted: Fri Feb 20, 2015 5:24 am
by luau
mackerelmint wrote:Nice!
Thanks.

I neglected to mention a couple things besides the user numbers. Once the script is installed into Greasemonkey it'll be saved in your Firefox profile in the gm_scripts/offsetguitars.com directory. The file can be directly edited there in any text editor with no need for any reinstallation steps. I expect other browsers are similar. Also, disable the board software's foe settings and let this script handle everything. Adding someone as a foe in the board software and in the script will probably cause problems.

Re: Foe Feature

Posted: Fri Feb 20, 2015 10:03 am
by mackerelmint
Ah, OK. I'll disable my fecal roster and see if that gets it to work. Thanks.

Re: Foe Feature

Posted: Fri Feb 20, 2015 10:34 am
by luau
The script still strips Foe's quotes from posts when Foe is on the board's foe list, but doesn't strip posts by Foe. Sorry about that.