Tip jar

If you like CaB and wish to support it, you can use PayPal or KoFi. Thank you, and I hope you continue to enjoy the site - Neil.

Buy Me a Coffee at ko-fi.com

Support CaB

Recent

Welcome to Cook'd and Bomb'd. Please login or sign up.

March 28, 2024, 02:58:48 PM

Login with username, password and session length

The block-user script is now available as a chrome extension

Started by Paul Calf, January 13, 2017, 10:59:01 PM

Previous topic - Next topic

Consignia


Endicott

Quote from: PaulTMA on January 16, 2020, 09:01:25 PM
Thanks.  Having a bit of headache with this.  What text is needing to be replaced - used name and their ID?  It doesn't seem to be working for me if so.

I think the text NoSleep is talking about is this line
expireAfter = 315360000000; //Milliseconds
he says to replace the number

Personally I think it's far easier to go to the bottom of the script and delete this line altogether
expireIgnores();

If you are having trouble you'll probably need to use the debugger mode F12 (it's F12 in Chrome, FF and IE probably the same) and tell us what errors are appearing in the console.

Endicott

Ah,
expireAfter = 315360000000; //Milliseconds

that is NoSleep's number that makes it last 10 years. The original script used 1209600000 ms

But as I say just remove or comment out the command to expire. Nothing else should need to change, but just in case there's some been some error copying the code, I've just copied this from out of my Tampermonkey. Look down the bottom you'll see I've used // to comment out the lines I don't personally like (eg the expire bit)

// ==UserScript==
// @name        Ignore Users on Cook'd and Bomb'd V4
// @namespace   http://www.stupidpupil.co.uk
// @include     https://www.cookdandbombd.co.uk/forums/*
// @include     http://www.cookdandbombd.co.uk/forums/*
// @grant       none
// @version     1.4
// ==/UserScript==
(function () {
        'use strict';

        var ignoredUsers, expireAfter, opacity;

        expireAfter = 1209600000; //Milliseconds
        opacity = '0.3';

        console.log('running');

        ignoredUsers = window.localStorage.getItem("ignoredUsers");
        if (ignoredUsers) {
            console.log(ignoredUsers);
            ignoredUsers = JSON.parse(ignoredUsers);
        } else {
            ignoredUsers = {};
        }

        //

        function expireIgnores() {
            var ignore, i;

            for (i in ignoredUsers) {
                ignore = ignoredUsers[i];

                if ((Date.now() - ignore.ignored) > expireAfter) {
                    unignoreUser(i);
                }
            }
        }

        function ignoreUser(uid, username) {
            ignoredUsers[uid] = {
                'username': username,
                'ignored': Date.now()
            };
            console.log('set ignore list  - add user');
            window.localStorage.setItem("ignoredUsers", JSON.stringify(ignoredUsers));
        }

        function unignoreUser(uid) {
            delete ignoredUsers[uid];
            console.log('set ignore list  - remove user');
            window.localStorage.setItem("ignoredUsers", JSON.stringify(ignoredUsers));
        }


        //

        function setIgnoreLink() {
            if (!window.location.search.match("action=profile;u=")) {
                return false;
            }
            var infolinks, anchor, uid;
            infolinks = document.getElementById("infolinks");
            anchor = document.getElementById("ignorelink");
            uid = window.location.search.replace(new RegExp(".+;u=(\\d+)"), "$1");


            if (anchor) {
                anchor.childNodes[0].remove();
            } else {
                anchor = document.createElement("a");
                anchor.setAttribute("href", "#ignorelink");
                anchor.setAttribute("id", "ignorelink");

                anchor.addEventListener("click", function () {
                    var cuid, username;
                    cuid = window.location.search.replace(new RegExp(".+;u=(\\d+)"), "$1");
                    username = document.getElementsByClassName("username")[0].textContent.trim();


                    if (ignoredUsers[cuid]) {
                        unignoreUser(cuid);
                    } else {
                        ignoreUser(cuid, username);
                    }

                    setIgnoreLink();
                    return false;
                });

                infolinks.appendChild(document.createElement("br"));
                infolinks.appendChild(anchor);
            }


            if (ignoredUsers[uid]) {
                anchor.appendChild(document.createTextNode("Unignore User"));
            } else {
                anchor.appendChild(document.createTextNode("Ignore User"));
            }

        }

        //

        function hideThreads() {
            console.log('hideThreads - begin');
            if (!window.location.href.match("board")) {
                return false;
            }
            console.log('hideThreads - continue');

            var subjects, subject, uid, i;
            subjects = document.getElementsByClassName('subject');
            for (i in subjects) {
                subject = subjects[i];
                if (typeof subject === 'object') {
                    if (subject.getElementsByTagName("p").length > 0) {
                        uid = subject.getElementsByTagName("p")[0].getElementsByTagName("a")[0].href.replace(new RegExp(".+u=(\\d+)"), "$1");
                        if (ignoredUsers[uid]) {
                            subject.parentNode.style.opacity = opacity;
                            if (subject.getElementsByTagName("span")) {
                                subject.getElementsByTagName("span")[0].style.display = "none";
                                subject.parentNode.getElementsByClassName("stats")[0].textContent = "";
                                subject.parentNode.getElementsByClassName("lastpost")[0].textContent = "";
                            }

                        }
                    }
                }
                else {
                    break;
                }
            }
            console.log('hideThreads - end');
        }

        function hidePostsAndPostsWithQuotes() {
            console.log('hidePosts - begin');
            if (!window.location.href.match("topic")) {
                return false;
            }
            console.log('hidePosts - continue');

            var posts, post, uid, i;
            var quoteheaders, qh, usernames, qusername, ignoreQuoted;

            usernames = [];
            for (i in ignoredUsers) {
                usernames.push(ignoredUsers[i].username);
            }

            posts = document.getElementsByClassName('post_wrapper');

            for (i in posts) {
                post = posts[i];
                if (post.getElementsByTagName) {
                    uid = post.getElementsByClassName("poster")[0].getElementsByTagName("h4")[0].getElementsByTagName("a")[0].href.replace(new RegExp(".+u=(\\d+)"), "$1");
                    ignoreQuoted = false;

                    quoteheaders = post.getElementsByClassName('quoteheader');
                    for (i in quoteheaders) {
                        qh = quoteheaders[i];
                        if (qh.textContent) {
                            qusername = qh.textContent.replace(new RegExp("Quote from: (.+?) on .+"), "$1").trim();
                            if (usernames.indexOf(qusername) > -1) {
                                ignoreQuoted = true;
                            }
                        }
                    }

                    if (ignoredUsers[uid] || ignoreQuoted) {
                        post.parentNode.style.opacity = opacity;
                        setDisplayNone(post, "avatar");
                        setDisplayNone(post, "post");
                        setDisplayNone(post, "keyinfo");
                        setDisplayNone(post, "reset");
                        setDisplayNone(post, "moderatorbar");
                        setDisplayNone(post, "quote_button");
                    }

                }
            }
            console.log('hidePosts - end');
        }

        function hidePosts() {
            console.log('hidePosts - begin');
            if (!window.location.href.match("topic")) {
                return false;
            }
            console.log('hidePosts - continue');

            var posts, post, uid, i;
            posts = document.getElementsByClassName('post_wrapper');

            for (i in posts) {
                post = posts[i];
                if (post.getElementsByTagName) {
                    uid = post.getElementsByClassName("poster")[0].getElementsByTagName("h4")[0].getElementsByTagName("a")[0].href.replace(new RegExp(".+u=(\\d+)"), "$1");

                    if (ignoredUsers[uid]) {
                        post.parentNode.style.opacity = opacity;
                        setDisplayNone(post, "avatar");
                        setDisplayNone(post, "post");
                        setDisplayNone(post, "keyinfo");
                        setDisplayNone(post, "reset");
                        setDisplayNone(post, "moderatorbar");
                        setDisplayNone(post, "quote_button");
                    }

                }
            }
            console.log('hidePosts - end');
        }
        function setDisplayNone(post, name) {
            if (post.getElementsByClassName(name)[0]) {
                post.getElementsByClassName(name)[0].style.display = "none";
            }
        }

        function hideQuotes() {
            console.log('hideQuotes - begin');
            if (!window.location.href.match("topic")) {
                return false;
            }
            console.log('hideQuotes - continue');

            var quoteheaders, qh, usernames, qusername, i;
            quoteheaders = document.getElementsByClassName('quoteheader');

            usernames = [];
            for (i in ignoredUsers) {
                usernames.push(ignoredUsers[i].username);
            }

            for (i in quoteheaders) {
                qh = quoteheaders[i];
                if (qh.textContent) {
                    qusername = qh.textContent.replace(new RegExp("Quote from: (.+?) on .+"), "$1").trim();

                    if (usernames.indexOf(qusername) > -1) {
                        qh.nextSibling.textContent = "";
                        qh.nextSibling.style.opacity = opacity;
                        qh.style.opacity = opacity;
                    }
                }
            }
            console.log('hideQuotes - end');
        }


        //expireIgnores(); // removed because I want control
        //hideThreads(); // removed because I found it annoying
        setIgnoreLink();
        //hidePostsAndPostsWithQuotes(); // if you use this bit, you don't need the next two lines, but it hides the responses as well - if you get it working then experiment, and you'll see what I mean
        hidePosts();
        hideQuotes();
    }
)
();


PaulTMA

That's OK, it's really about getting the insufferable person's name and ID in the right places.  Where exactly do they go?  I managed this on ilxor at least.

Endicott

If I've understood your problem correctly ....

You don't edit the script, you go to the user's profile page, where you'll find a link saying Ignore User. Once you've clicked it, it changes to Unignore User.


Endicott

And if that isn't working for you, let me know and I'll work out how to hard code them. It's not hard but it's late, so it won't be tonight.

NoSleep

Once it's installed you go to the person who you wish to block's profile and you will see "ignore user" is now an option below "show stats". Just click that and all their posts will be blocked. If you change your mind then go back to their stats and click "unignore user".

EDIT: snap

Mister Six


PaulTMA

Ah well, never managed it but it's swings and roundabouts I guess sometimes

Blue Jam

Sorry to bump this, but could anyone please post up a simple installation guide or suggest what I may be doing wrong here? I've got the following code:

// ==UserScript==
// @name        Ignore Users on Cook'd and Bomb'd
// @namespace   http://www.stupidpupil.co.uk
// @include     https://www.cookdandbombd.co.uk/forums/*
// @include     http://www.cookdandbombd.co.uk/forums/*
// @grant       none
// @version     1.0
// ==/UserScript==
(function () {
        'use strict';

        var ignoredUsers, expireAfter, opacity;

        expireAfter = 1209600000; //Milliseconds
        opacity = '0.3';

        ignoredUsers = window.localStorage.getItem("ignoredUsers");
        if (ignoredUsers) {
            ignoredUsers = JSON.parse(ignoredUsers);
        } else {
            ignoredUsers = {};
        }

        //

        function expireIgnores() {
            var ignore, i;

            for (i in ignoredUsers) {
                ignore = ignoredUsers[i];

                if ((Date.now() - ignore.ignored) > expireAfter) {
                    unignoreUser(i);
                }
            }
        }

        function ignoreUser(uid, username) {
            ignoredUsers[uid] = {
                'username': username,
                'ignored': Date.now()
            };
            window.localStorage.setItem("ignoredUsers", JSON.stringify(ignoredUsers));
        }

        function unignoreUser(uid) {
            delete ignoredUsers[uid];
            window.localStorage.setItem("ignoredUsers", JSON.stringify(ignoredUsers));
        }


        //

        function setIgnoreLink() {
            if (!window.location.search.match("action=profile;u=")) {
                return false;
            }
            var infolinks, anchor, uid;
            infolinks = document.getElementById("infolinks");
            anchor = document.getElementById("ignorelink");
            uid = window.location.search.replace(new RegExp(".+;u=(\\d+)"), "$1");


            if (anchor) {
                anchor.childNodes[0].remove();
            } else {
                anchor = document.createElement("a");
                anchor.setAttribute("href", "#ignorelink");
                anchor.setAttribute("id", "ignorelink");

                anchor.addEventListener("click", function () {
                    var cuid, username;
                    cuid = window.location.search.replace(new RegExp(".+;u=(\\d+)"), "$1");
                    username = document.getElementsByClassName("username")[0].textContent.trim();


                    if (ignoredUsers[cuid]) {
                        unignoreUser(cuid);
                    } else {
                        ignoreUser(cuid, username);
                    }

                    setIgnoreLink();
                    return false;
                });

                infolinks.appendChild(document.createElement("br"));
                infolinks.appendChild(anchor);
            }


            if (ignoredUsers[uid]) {
                anchor.appendChild(document.createTextNode("Unignore User"));
            } else {
                anchor.appendChild(document.createTextNode("Ignore User"));
            }

        }

        //

        function hideThreads() {
            if (!window.location.href.match("board")) {
                return false;
            }

            var subjects, subject, uid, i;
            subjects = document.getElementsByClassName('subject');
            for (i in subjects) {
                subject = subjects[i];
                if(typeof subject !== 'object') {
                    break;
                }
                if (subject.getElementsByTagName("p").length > 0) {
                    uid = subject.getElementsByTagName("p")[0].getElementsByTagName("a")[0].href.replace(new RegExp(".+u=(\\d+)"), "$1");
                    if (ignoredUsers[uid]) {
                        subject.parentNode.style.opacity = opacity;
                        if (subject.getElementsByTagName("span")) {
                            subject.getElementsByTagName("span")[0].style.display = "none";
                            subject.parentNode.getElementsByClassName("stats")[0].textContent = "";
                            subject.parentNode.getElementsByClassName("lastpost")[0].textContent = "";
                        }

                    }
                }
            }
        }

        function hidePosts() {
            if (!window.location.href.match("topic")) {
                return false;
            }

            var posts, post, uid, i;
            posts = document.getElementsByClassName('post_wrapper');

            for (i in posts) {
                post = posts[i];
                if (post.getElementsByTagName) {
                    uid = post.getElementsByClassName("poster")[0].getElementsByTagName("h4")[0].getElementsByTagName("a")[0].href.replace(new RegExp(".+u=(\\d+)"), "$1");

                    if (ignoredUsers[uid]) {
                        post.parentNode.style.opacity = opacity;
                        setDisplayNone(post, "avatar");
                        setDisplayNone(post, "post");
                        setDisplayNone(post, "keyinfo");
                        setDisplayNone(post, "reset");
                        setDisplayNone(post, "moderatorbar");
                        setDisplayNone(post, "quote_button");
                    }
                }
            }
        }

        function setDisplayNone(post, name) {
            if (post.getElementsByClassName(name)[0])
                post.getElementsByClassName(name)[0].style.display = "none";
        }

        function hideQuotes() {
            if (!window.location.href.match("topic")) {
                return false;
            }

            var quoteheaders, qh, usernames, qusername, i;
            quoteheaders = document.getElementsByClassName('quoteheader');

            usernames = [];
            for (i in ignoredUsers) {
                usernames.push(ignoredUsers[i].username);
            }

            for (i in quoteheaders) {
                qh = quoteheaders[i];
                qusername = qh.textContent.replace(new RegExp("Quote from: (.+?) on .+"), "$1").trim();

                if (usernames.indexOf(qusername) > -1) {
                    qh.nextSibling.textContent = "";
                    qh.nextSibling.style.opacity = opacity;
                    qh.style.opacity = opacity;
                }
            }
        }

        expireIgnores();
        setIgnoreLink();
        hidePosts();
        hideThreads();
        hideQuotes();
    }
)
();


On Chrome I have Tampermonkey installed. I go to the Tampermonkey dashboard, I click the + sign, I paste in the code and click "Save", and then... nothing. I get a little badge on the Tampermonkey icon in the Extensions menu, and if I hover over that it tells me "Tampermonkey is active on this site" but there is still no Block User option. I get the exact same result with Greasemonkey on Firefox. Is there some little tweak I have to make?

Consignia

Sticking it into the browser console, I get an error on the following line:

                qusername = qh.textContent.replace(new RegExp("Quote from: (.+?) on .+"), "$1").trim();


With the error: Cannot read property 'replace' of undefined

Removing that line from the source makes it work, but it'll stop block quotes from ignored users.

This bodge should fix it:
// ==UserScript==
// @name        Ignore Users on Cook'd and Bomb'd
// @namespace   http://www.stupidpupil.co.uk
// @include     https://www.cookdandbombd.co.uk/forums/*
// @include     http://www.cookdandbombd.co.uk/forums/*
// @grant       none
// @version     1.0
// ==/UserScript==
(function () {
        'use strict';

        var ignoredUsers, expireAfter, opacity;

        expireAfter = 1209600000; //Milliseconds
        opacity = '0.3';

        ignoredUsers = window.localStorage.getItem("ignoredUsers");
        if (ignoredUsers) {
            ignoredUsers = JSON.parse(ignoredUsers);
        } else {
            ignoredUsers = {};
        }

        //

        function expireIgnores() {
            var ignore, i;

            for (i in ignoredUsers) {
                ignore = ignoredUsers[i];

                if ((Date.now() - ignore.ignored) > expireAfter) {
                    unignoreUser(i);
                }
            }
        }

        function ignoreUser(uid, username) {
            ignoredUsers[uid] = {
                'username': username,
                'ignored': Date.now()
            };
            window.localStorage.setItem("ignoredUsers", JSON.stringify(ignoredUsers));
        }

        function unignoreUser(uid) {
            delete ignoredUsers[uid];
            window.localStorage.setItem("ignoredUsers", JSON.stringify(ignoredUsers));
        }


        //

        function setIgnoreLink() {
            if (!window.location.search.match("action=profile;u=")) {
                return false;
            }
            var infolinks, anchor, uid;
            infolinks = document.getElementById("infolinks");
            anchor = document.getElementById("ignorelink");
            uid = window.location.search.replace(new RegExp(".+;u=(\\d+)"), "$1");


            if (anchor) {
                anchor.childNodes[0].remove();
            } else {
                anchor = document.createElement("a");
                anchor.setAttribute("href", "#ignorelink");
                anchor.setAttribute("id", "ignorelink");

                anchor.addEventListener("click", function () {
                    var cuid, username;
                    cuid = window.location.search.replace(new RegExp(".+;u=(\\d+)"), "$1");
                    username = document.getElementsByClassName("username")[0].textContent.trim();


                    if (ignoredUsers[cuid]) {
                        unignoreUser(cuid);
                    } else {
                        ignoreUser(cuid, username);
                    }

                    setIgnoreLink();
                    return false;
                });

                infolinks.appendChild(document.createElement("br"));
                infolinks.appendChild(anchor);
            }


            if (ignoredUsers[uid]) {
                anchor.appendChild(document.createTextNode("Unignore User"));
            } else {
                anchor.appendChild(document.createTextNode("Ignore User"));
            }

        }

        //

        function hideThreads() {
            if (!window.location.href.match("board")) {
                return false;
            }

            var subjects, subject, uid, i;
            subjects = document.getElementsByClassName('subject');
            for (i in subjects) {
                subject = subjects[i];
                if(typeof subject !== 'object') {
                    break;
                }
                if (subject.getElementsByTagName("p").length > 0) {
                    uid = subject.getElementsByTagName("p")[0].getElementsByTagName("a")[0].href.replace(new RegExp(".+u=(\\d+)"), "$1");
                    if (ignoredUsers[uid]) {
                        subject.parentNode.style.opacity = opacity;
                        if (subject.getElementsByTagName("span")) {
                            subject.getElementsByTagName("span")[0].style.display = "none";
                            subject.parentNode.getElementsByClassName("stats")[0].textContent = "";
                            subject.parentNode.getElementsByClassName("lastpost")[0].textContent = "";
                        }

                    }
                }
            }
        }

        function hidePosts() {
            if (!window.location.href.match("topic")) {
                return false;
            }

            var posts, post, uid, i;
            posts = document.getElementsByClassName('post_wrapper');

            for (i in posts) {
                post = posts[i];
                if (post.getElementsByTagName) {
                    uid = post.getElementsByClassName("poster")[0].getElementsByTagName("h4")[0].getElementsByTagName("a")[0].href.replace(new RegExp(".+u=(\\d+)"), "$1");

                    if (ignoredUsers[uid]) {
                        post.parentNode.style.opacity = opacity;
                        setDisplayNone(post, "avatar");
                        setDisplayNone(post, "post");
                        setDisplayNone(post, "keyinfo");
                        setDisplayNone(post, "reset");
                        setDisplayNone(post, "moderatorbar");
                        setDisplayNone(post, "quote_button");
                    }
                }
            }
        }

        function setDisplayNone(post, name) {
            if (post.getElementsByClassName(name)[0])
                post.getElementsByClassName(name)[0].style.display = "none";
        }

        function hideQuotes() {
            if (!window.location.href.match("topic")) {
                return false;
            }

            var quoteheaders, qh, usernames, qusername, i;
            quoteheaders = document.getElementsByClassName('quoteheader');

            usernames = [];
            for (i in ignoredUsers) {
                usernames.push(ignoredUsers[i].username);
            }

            for (i in quoteheaders) {
                qh = quoteheaders[i];
                var myTextContent = qh.textContent;
               if(myTextContent && myTextContent.replace) {
                qusername = myTextContent.replace(new RegExp("Quote from: (.+?) on .+"), "$1").trim();
               }

                if (usernames.indexOf(qusername) > -1) {
                    qh.nextSibling.textContent = "";
                    qh.nextSibling.style.opacity = opacity;
                    qh.style.opacity = opacity;
                }
            }
        }

        expireIgnores();
        setIgnoreLink();
        hidePosts();
        hideThreads();
        hideQuotes();
    }
)
();


Works for me, but not my code so no guarantee I'm afriad.

Endicott

When you say 'there is no block user option' do you mean that



the highlighted Ignore (or Unignore) User is missing? (in the past some people just haven't realised that this is where to look for it)

Blue Jam

Endicott - yes, this is exactly what I mean. I did once get an early version of the script (think it was the Goldfinger one) working on an old Windows 7 laptop years ago and the Ignore User option was present and correct then but I haven't been able to make it appear on the two laptops I've had since (Windows 7 and Windows 10 respectively).

Consignia- thanks for your hard work, I really appreciate it, but it's still not working for me. I'm going a bit mad here wondering how I'm being such a n00b when it seems so simple and it's working for everyone else.

Kankurette

I see this script has gone down well, judging by the tags.

popcorn

Nice try Blue Jam but you'll never block me.

Quote from: Kankurette on May 12, 2021, 04:06:48 PM
I see this script has gone down well, judging by the tags.

Tags just a way for horrible people to write horrible shit, we shouldn't have em.

madhair60

putting me on ignore counts as admitting to being a paedophile.

Endicott

The bit of code you've posted that puts the link up on the profile page looks fine to me (it's the function called setIgnoreLink).

Try this:

Go to a profile page, and confirm that in the URL you see index.php?action=profile;u=
Specifically the bit in bold. There'll be a number after it.
If you don't see that when on a profile page, what do you see?

If you do see that, then press F12 to get diagnostic window and make sure the console tab is displayed, then refresh the page. Are there any errors listed in the console?

Blue Jam

Quote from: Endicott on May 12, 2021, 04:23:07 PM
Go to a profile page, and confirm that in the URL you see index.php?action=profile;u=
Specifically the bit in bold. There'll be a number after it.

Yes, I do see that.

QuoteIf you do see that, then press F12 to get diagnostic window and make sure the console tab is displayed, then refresh the page. Are there any errors listed in the console?

No :'(

Sorry, I'm a total n00b when it comes to code and whenever I've had to do coding for werk I've struggled. I admire anyone who can do it well and understand it as the artform it clearly is.

idunnosomename

Quote from: popcorn on May 12, 2021, 04:08:57 PM
Nice try Blue Jam but you'll never block me.

Tags just a way for horrible people to write horrible shit, we shouldn't have em.
oh why's that then

Consignia

Quote from: Blue Jam on May 12, 2021, 04:04:30 PM

Consignia- thanks for your hard work, I really appreciate it, but it's still not working for me. I'm going a bit mad here wondering how I'm being such a n00b when it seems so simple and it's working for everyone else.

Ah, soz. I thought it may be a Chrome being finnicky about JavaScript issue. I do have my own script which is much simpler, but requires manual updating if you want to ignore a user, and doesn't expire like the other one eventually does. If you're still have issues later and are interested, I can DM it you once I'm on my own laptop.

Barry Admin

Quote from: popcorn on May 12, 2021, 04:08:57 PM
Tags just a way for horrible people to write horrible shit, we shouldn't have em.

We barely do, so it's hardly worth crying about them.

Moved to the tech forum.

Bunty Levert

Quote from: popcorn on May 12, 2021, 04:08:57 PM
Tags just a way for horrible people to write horrible shit, we shouldn't have em.


// ==UserScript==
// @name        Cook'd and Bomb'd Hide Tags
// @description Hides tags under topic pages
// @namespace   https://github.com/insin/greasemonkey/
// @version     1
// @match       https://www.cookdandbombd.co.uk/forums/index.php/topic*
// ==/UserScript==

let $style = document.createElement('style')
$style.innerText = '#main_content_section .pagesection + .largepadding { display: none; }'
document.head.appendChild($style)

Blue Jam

Quote from: popcorn on May 12, 2021, 04:08:57 PM
Nice try Blue Jam but you'll never block me.

Tags just a way for horrible people to write horrible shit, we shouldn't have em.

Nah you're alright poppers

Agree with you on tags, glad tags and karma have gone. The only time I miss tags is in the celebrity death threads, that's what they're really for.

Blue Jam

Quote from: Consignia on May 12, 2021, 04:33:55 PM
Ah, soz. I thought it may be a Chrome being finnicky about JavaScript issue. I do have my own script which is much simpler, but requires manual updating if you want to ignore a user, and doesn't expire like the other one eventually does. If you're still have issues later and are interested, I can DM it you once I'm on my own laptop.

Ah yes, that makes total sense now. I think this might be relevant:

https://www.geeksforgeeks.org/web-browsers-that-support-java-applets-and-how-to-enable-them/

This might explain why I was able to get the script working on an old laptop but not forever, and not on newer laptops with newer browsers!

I would really appreciate the code if you could send it, cheers. Manual updating is fine for me, used something like that for another forum once and it was fine. Big thanks for all your effort here.

Zetetic

Nah, Java and JavaScript are almost completely unrelated (confusingly).

I remain surprised no-one's rewritten "the ignore script" at this point, given how badly made it is.

Barry Admin

I might just turn it on natively now. I remain unconvinced that people will use it. Site seems full of people constantly threatening to leave it these days, and I don't think CaB is the issue, I just think people have a different attitude to the net now.

Blue Jam

I'd really appreciate that Neil, if it too much of a headache for you. Thanks for dropping by here.

And I'm sorry I'm such a mentally fragile n00b, need to filter out a few things for my own sanity right now.

Endicott

Quote from: Blue Jam on May 12, 2021, 04:32:01 PM
Yes, I do see a that.

No :'(

Sorry, I'm a total n00b when it comes to code and whenever I've had to do coding for werk I've struggled. I admire anyone who can do it well and understand it as the artform it clearly is.

It's a bit tricky to diagnose without any obvious errors, I'm afraid.

One last try, use this version. It's got added console diagnostic messages (and bug fixes including what Consignia found). The go to a profile page and get the console up again. refresh that profile page, you should see in the console

ignore script running
begin creating ignore link
add ignore link event listener
added ignore link
hidePosts - begin
hideQuotes - begin


// ==UserScript==
// @name        Ignore Users on Cook'd and Bomb'd V4
// @namespace   http://www.stupidpupil.co.uk
// @include     https://www.cookdandbombd.co.uk/forums/*
// @include     http://www.cookdandbombd.co.uk/forums/*
// @grant       none
// @version     1.5
// ==/UserScript==
(function () {
        'use strict';

        var ignoredUsers, expireAfter, opacity;

        expireAfter = 1209600000; //Milliseconds
        opacity = '0.3';

        console.log('ignore script running');

        ignoredUsers = window.localStorage.getItem("ignoredUsers");
        if (ignoredUsers) {
            //console.log(ignoredUsers);
            ignoredUsers = JSON.parse(ignoredUsers);
        } else {
            ignoredUsers = {};
        }

        //

        function expireIgnores() {
            var ignore, i;

            for (i in ignoredUsers) {
                ignore = ignoredUsers[i];

                if ((Date.now() - ignore.ignored) > expireAfter) {
                    unignoreUser(i);
                }
            }
        }

        function ignoreUser(uid, username) {
            ignoredUsers[uid] = {
                'username': username,
                'ignored': Date.now()
            };
            console.log('set ignore list  - add user');
            window.localStorage.setItem("ignoredUsers", JSON.stringify(ignoredUsers));
        }

        function unignoreUser(uid) {
            delete ignoredUsers[uid];
            console.log('set ignore list  - remove user');
            window.localStorage.setItem("ignoredUsers", JSON.stringify(ignoredUsers));
        }


        //

        function setIgnoreLink() {
            if (!window.location.search.match("action=profile;u=")) {
                return false;
            }
            var infolinks, anchor, uid;
            infolinks = document.getElementById("infolinks");
            anchor = document.getElementById("ignorelink");
            uid = window.location.search.replace(new RegExp(".+;u=(\\d+)"), "$1");


            if (anchor) {
                anchor.childNodes[0].remove();
                console.log('removing ignore link');
            } else {
                console.log('begin creating ignore link');
                anchor = document.createElement("a");
                anchor.setAttribute("href", "#ignorelink");
                anchor.setAttribute("id", "ignorelink");

                console.log('add ignore link event listener');
                anchor.addEventListener("click", function () {
                    var cuid, username;
                    cuid = window.location.search.replace(new RegExp(".+;u=(\\d+)"), "$1");
                    username = document.getElementsByClassName("username")[0].textContent.trim();


                    if (ignoredUsers[cuid]) {
                        unignoreUser(cuid);
                    } else {
                        ignoreUser(cuid, username);
                    }

                    setIgnoreLink();
                    return false;
                });

                infolinks.appendChild(document.createElement("br"));
                infolinks.appendChild(anchor);
                console.log('added ignore link');
            }


            if (ignoredUsers[uid]) {
                anchor.appendChild(document.createTextNode("Unignore User"));
            } else {
                anchor.appendChild(document.createTextNode("Ignore User"));
            }

        }

        //

        function hideThreadsInHsArt() {
            console.log('hideThreadsInHsArt - begin');
            if (!window.location.href.match("action=unread")) {
                return false;
            }
            console.log('hideThreadsInHsArt - continue');

            var subjects, subject, i, f_link;
            subjects = document.getElementsByClassName('subject');
            for (i in subjects) {
                subject = subjects[i];
                if (typeof subject === 'object') {
                    if (subject.getElementsByTagName("p").length > 0) {
                        f_link = subject.getElementsByTagName("p")[0].getElementsByTagName("a")[1];
                        if (f_link.innerText == "H.S. Art") {
                            //subject.parentNode.style.display = "none";
                            subject.parentNode.style.opacity = opacity;
                        }
                    }
                }
                else {
                    break;
                }
            }
            console.log('hideThreads - end');
        }


        function hideThreads() {
            console.log('hideThreads - begin');
            if (!window.location.href.match("board")) {
                return false;
            }
            console.log('hideThreads - continue');

            var subjects, subject, uid, i;
            subjects = document.getElementsByClassName('subject');
            for (i in subjects) {
                subject = subjects[i];
                if (typeof subject === 'object') {
                    if (subject.getElementsByTagName("p").length > 0) {
                        uid = subject.getElementsByTagName("p")[0].getElementsByTagName("a")[0].href.replace(new RegExp(".+u=(\\d+)"), "$1");
                        if (ignoredUsers[uid]) {
                            subject.parentNode.style.opacity = opacity;
                            if (subject.getElementsByTagName("span")) {
                                subject.getElementsByTagName("span")[0].style.display = "none";
                                subject.parentNode.getElementsByClassName("stats")[0].textContent = "";
                                subject.parentNode.getElementsByClassName("lastpost")[0].textContent = "";
                            }

                        }
                    }
                }
                else {
                    break;
                }
            }
            console.log('hideThreads - end');
        }

        function hidePostsAndPostsWithQuotes() {
            console.log('hidePosts - begin');
            if (!window.location.href.match("topic")) {
                return false;
            }
            console.log('hidePosts - continue');

            var posts, post, uid, i;
            var quoteheaders, qh, usernames, qusername, ignoreQuoted;

            usernames = [];
            for (i in ignoredUsers) {
                usernames.push(ignoredUsers[i].username);
            }

            posts = document.getElementsByClassName('post_wrapper');

            for (i in posts) {
                post = posts[i];
                if (post.getElementsByTagName) {
                    uid = post.getElementsByClassName("poster")[0].getElementsByTagName("h4")[0].getElementsByTagName("a")[0].href.replace(new RegExp(".+u=(\\d+)"), "$1");
                    ignoreQuoted = false;

                    quoteheaders = post.getElementsByClassName('quoteheader');
                    for (i in quoteheaders) {
                        qh = quoteheaders[i];
                        if (qh.textContent) {
                            qusername = qh.textContent.replace(new RegExp("Quote from: (.+?) on .+"), "$1").trim();
                            if (usernames.indexOf(qusername) > -1) {
                                ignoreQuoted = true;
                            }
                        }
                    }

                    if (ignoredUsers[uid] || ignoreQuoted) {
                        post.parentNode.style.opacity = opacity;
                        setDisplayNone(post, "avatar");
                        setDisplayNone(post, "post");
                        setDisplayNone(post, "keyinfo");
                        setDisplayNone(post, "reset");
                        setDisplayNone(post, "moderatorbar");
                        setDisplayNone(post, "quote_button");
                    }

                }
            }
            console.log('hidePosts - end');
        }

        function hidePosts() {
            console.log('hidePosts - begin');
            if (!window.location.href.match("topic")) {
                return false;
            }
            console.log('hidePosts - continue');

            var posts, post, uid, i;
            posts = document.getElementsByClassName('post_wrapper');

            for (i in posts) {
                post = posts[i];
                if (post.getElementsByTagName) {
                    uid = post.getElementsByClassName("poster")[0].getElementsByTagName("h4")[0].getElementsByTagName("a")[0].href.replace(new RegExp(".+u=(\\d+)"), "$1");

                    if (ignoredUsers[uid]) {
                        post.parentNode.style.opacity = opacity;
                        setDisplayNone(post, "avatar");
                        setDisplayNone(post, "post");
                        setDisplayNone(post, "keyinfo");
                        setDisplayNone(post, "reset");
                        setDisplayNone(post, "moderatorbar");
                        setDisplayNone(post, "quote_button");
                    }

                }
            }
            console.log('hidePosts - end');
        }
        function setDisplayNone(post, name) {
            if (post.getElementsByClassName(name)[0]) {
                post.getElementsByClassName(name)[0].style.display = "none";
            }
        }

        function hideQuotes() {
            console.log('hideQuotes - begin');
            if (!window.location.href.match("topic")) {
                return false;
            }
            console.log('hideQuotes - continue');

            var quoteheaders, qh, usernames, qusername, i;
            quoteheaders = document.getElementsByClassName('quoteheader');

            usernames = [];
            for (i in ignoredUsers) {
                usernames.push(ignoredUsers[i].username);
            }

            for (i in quoteheaders) {
                qh = quoteheaders[i];
                if (qh.textContent) {
                    qusername = qh.textContent.replace(new RegExp("Quote from: (.+?) on .+"), "$1").trim();

                    if (usernames.indexOf(qusername) > -1) {
                        qh.nextSibling.textContent = "";
                        qh.nextSibling.style.opacity = opacity;
                        qh.style.opacity = opacity;
                    }
                }
            }
            console.log('hideQuotes - end');
        }

        setIgnoreLink();
        hidePosts();
        hideQuotes();
    }
)
();



Quote from: Zetetic on May 12, 2021, 04:57:02 PM
Nah, Java and JavaScript are almost completely unrelated (confusingly).

I remain surprised no-one's rewritten "the ignore script" at this point, given how badly made it is.

Well I've bug fixed it as far as I can, but that's enough effort for me!

Barry Admin

Quote from: Blue Jam on May 12, 2021, 05:02:10 PM
I'd really appreciate that Neil, if it too much of a headache for you. Thanks for dropping by here.

And I'm sorry I'm such a mentally fragile n00b, need to filter out a few things for my own sanity right now.

Yeah I understand, no probs :-) chin up.

Endicott

Quote from: Zetetic on May 12, 2021, 04:57:02 PM
Nah, Java and JavaScript are almost completely unrelated (confusingly).

I remain surprised no-one's rewritten "the ignore script" at this point, given how badly made it is.

Do you remember why this function is checking for the existence of anchor ("ignorelink")? Is it to defend against Barry switching on native ignore functionality? This code really isn't as bad as you make out /smiley face/

        function setIgnoreLink() {
            if (!window.location.search.match("action=profile;u=")) {
                return false;
            }
            var infolinks, anchor, uid;
            infolinks = document.getElementById("infolinks");
            anchor = document.getElementById("ignorelink");
            uid = window.location.search.replace(new RegExp(".+;u=(\\d+)"), "$1");


            if (anchor) {
                anchor.childNodes[0].remove();
                console.log('removing ignore link');
            } else {
                console.log('begin creating ignore link');
                anchor = document.createElement("a");
                anchor.setAttribute("href", "#ignorelink");
                anchor.setAttribute("id", "ignorelink");

                console.log('add ignore link event listener');
                anchor.addEventListener("click", function () {
                    var cuid, username;
                    cuid = window.location.search.replace(new RegExp(".+;u=(\\d+)"), "$1");
                    username = document.getElementsByClassName("username")[0].textContent.trim();


                    if (ignoredUsers[cuid]) {
                        unignoreUser(cuid);
                    } else {
                        ignoreUser(cuid, username);
                    }

                    setIgnoreLink();
                    return false;
                });

                infolinks.appendChild(document.createElement("br"));
                infolinks.appendChild(anchor);
                console.log('added ignore link');
            }


            if (ignoredUsers[uid]) {
                anchor.appendChild(document.createTextNode("Unignore User"));
            } else {
                anchor.appendChild(document.createTextNode("Ignore User"));
            }

        }