Kill those annoying threads (FireFox only)

  • Hey Guest, Early bird pricing on the Summer Moot (29th July - 10th August) available until April 6th, we'd love you to come. PLEASE CLICK HERE to early bird price and get more information.

gregorach

Bushcrafter (boy, I've got a lot to say!)
Sep 15, 2005
3,723
28
50
Edinburgh
waking the dead her i know but,
i get a ignored thread list (blank) but no ignore this thread buttons
any help please

Yeah, it doesn't work with the new version of the forum and I haven't got around to fixing it yet. Maybe if somebody starts a really annoying thread... ;)
 

locum76

Bushcrafter (boy, I've got a lot to say!)
Oct 9, 2005
2,772
9
47
Kirkliston
I noticed you haven't posted on many threads recently except this one. Have you killed all of them apart from this one. :D
 

gregorach

Bushcrafter (boy, I've got a lot to say!)
Sep 15, 2005
3,723
28
50
Edinburgh
Yeah, it doesn't work with the new version of the forum and I haven't got around to fixing it yet. Maybe if somebody starts a really annoying thread... ;)

OK, in honour of Gary's new Global Warming poll, here's a revised version of this script that actually works on the new forum layout and with whatever changes have happened in GM / FF since I last did it:

Code:
// ==UserScript==
// @name           vBulletin Kill Thread
// @namespace      http://killthread.gregorach.com/
// @description    Kill threads in vBulletin
// @include        http://www.bushcraftuk.com/forum/*
// ==/UserScript==

/*===================================================================================*\
| For vBulletin ???                                                                   |
| 2008 By Gregorach                                                                   |
| Ripped off from soemthing ripped off from Google Groups Killfile v3.5.1             |
|    2008 by Damian Penney, Tim & Jeff Ur                                             |
\*===================================================================================*/

// Start

var showing = false;

unsafeWindow.closeThreadthreadKillList = function() {
    var killDiv = document.getElementById("threadKillList");
    killDiv.style.visibility = "hidden";
}

unsafeWindow._ThreadReanimate = function(killspec) {
    window.setTimeout(Reanimate, 0, killspec);
}

unsafeWindow._ThreadKillFile_Set = function(killspec, title) {
    killspec = killspec.replace(/^\s+|\s+$/g, "");
    window.setTimeout(SetKillFile, 0, killspec, title);
}

unsafeWindow._Purge = function() {
    window.setTimeout(updateKillFile, 0, Array(), new Array());
    alert("KillFile Purged.\nRefresh page to see changes.");
}


function JavaScriptEscape(text) {
    if (!arguments.callee.sRE) {
        var specials = [
      '"', '\'', '\\'
    ];
        arguments.callee.sRE = new RegExp(
      '(\\' + specials.join('|\\') + ')', 'g'
    );
    }
    return escape(text.replace(arguments.callee.sRE, '\\$1'));
}

function QuoteEscape(text) {
    if (!arguments.callee.sRE) {
        var specials = [
      '\''
    ];
        arguments.callee.sRE = new RegExp(
      '(\\' + specials.join('|\\') + ')', 'g'
    );
    }
    return escape(text.replace(arguments.callee.sRE, '\\$1'));
}

function RegExpEscape(text) {
    if (!arguments.callee.sRE) {
        var specials = [
      '/', '.', '*', '+', '?', '|',
      '(', ')', '[', ']', '{', '}', '\\'
    ];
        arguments.callee.sRE = new RegExp(
      '(\\' + specials.join('|\\') + ')', 'g'
    );
    }
    return text.replace(arguments.callee.sRE, '\\$1');
}

function Reanimate(killspec) {
    var splitCh = String.fromCharCode(255);
    var data = "";
    var titleData = "";
    var list = new Array();
    var titleList = new Array();
    var newList = new Array();
    var newTitleList = new Array();
    var title = "";

    // initialize variables

    data = unescape(GM_getValue("ThreadKillFile", "-----"));
    list = data.split(splitCh);

    titleData = unescape(GM_getValue("ThreadTitleKillFile", "-----"));
    titleList = titleData.split(splitCh);

    for (var j = 0; j < list.length; j++) {
        if (list[j] != killspec) {
            newList.push(list[j]);
            newTitleList.push(titleList[j]);
        } else {
            title = titleList[j];
        }
    }
    updateKillFile(newList, newTitleList);
    alert('"' + title + '" has been removed from the KillFile.\nRefresh page to see changes.');
}

function SetKillFile(killspec, title) {
    var splitCh = String.fromCharCode(255);
    var data = "";
    var titleData = "";
    var list = new Array();
    var titleList = new Array();

    // initialize variables

    data = unescape(GM_getValue("ThreadKillFile", "-----"));
    list = data.split(splitCh);
    list.push(RegExpEscape(killspec));

    titleData = unescape(GM_getValue("ThreadTitleKillFile", "-----"));
    titleList = titleData.split(splitCh);
    titleList.push(title);

    updateKillFile(list, titleList);
    
    try {
        var targetLink = document.getElementById("thread_title_" + killspec);
        var wrappingTable = document.evaluate("ancestor::li", targetLink, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
        GM_log("stripping comment from thread view");

        var pNode = wrappingTable.snapshotItem(0);
        pNode.parentNode.removeChild(pNode);

        alert('"' + title + '" has been added to the KillFile.');
    } catch (ex) {
        alert('"' + title + '" has been added to the KillFile.\nRefresh page to see  changes.');
    }
}

unsafeWindow.ManageThreadKillFile = function() {
    var killDiv = document.getElementById("threadKillList");
    if (showing == false) {
        killDiv.style.visibility = "visible";
        showing = true;
    } else {
        killDiv.style.visibility = "hidden";
        showing = false;
    }
}

function GroupsBeta_Thread_List_View(list) {
    // Delete comments in thread comment view

    var threads = document.getElementById('searchbits');
    if(!threads) threads = document.getElementById('thread_inlinemod_form');
    if (!threads) return;

    var candidates = document.evaluate(".//div[@class='inner']/h3/a[last()]", threads, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
    var blocked = false;
    var threadLinkRE = new RegExp("showthread\.php.t=([0-9]+)")

    if (candidates.snapshotLength > 0) {
        for (var i = 0; i < candidates.snapshotLength; i++) {
            var cand = candidates.snapshotItem(i);
            if (threadLinkRE.test(cand.getAttribute("href"))) {
                var threadId = threadLinkRE.exec(cand.getAttribute("href"))[1];
                var title = cand.textContent;
                blocked = false;

                for (var j = 0; !blocked && j < list.length; j++) {
                    if (threadId == list[j]) {
                        wrappingTable = document.evaluate("ancestor::li", cand, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
                        GM_log("stripping comment from thread view");

                        var pNode = wrappingTable.snapshotItem(0);
                        pNode.parentNode.removeChild(pNode);
                        blocked = true;
                    }
                }

                if (!blocked) {
                    var spacer = document.createTextNode(" ");
                    var link = document.createElement("a");
                    link.href = "javascript:_ThreadKillFile_Set('" + threadId + "', '" + QuoteEscape(title) + "');";

                    cand.parentNode.appendChild(spacer);
                    link.appendChild(document.createTextNode("[Ignore]"));

                    cand.parentNode.appendChild(link);
                    blocked = false;
                }
            }
        }
    }
}

function updateKillFile(list, titleList) {
    var splitCh = String.fromCharCode(255);

    data = list.join(splitCh);
    window.setTimeout(function() {GM_setValue("ThreadKillFile", escape(data))}, 0);

    titleData = titleList.join(splitCh);
    window.setTimeout(function() {GM_setValue("ThreadTitleKillFile", escape(titleData))}, 0);
    
    updateKillFileText(list, titleList);
}

function updateKillFileText(list, titleList) {
    var newDiv = document.getElementById("threadKillList");

    var divHtml = "<b>Ignored Thread List</b>";
    divHtml = divHtml + "<span style='float:right;'><a href=\"javascript:closeThreadthreadKillList ();\" style='color:#000000;'>CLOSE</a></span>";
    divHtml += '<br/><br/>';
    divHtml += "X - remove from list<br/>"

    for (var j = 1; j < list.length; j++) {
        divHtml += "<a href=\"javascript:_ThreadReanimate('" + JavaScriptEscape(list[j]) + "');\" style='color:#000000;'>X</a> " 
	      + titleList[j] + "<br/>";
    }

    divHtml += "<br/><br/><a href=\"javascript:_Purge()\" style='color:#000000;'>Purge List</a>"
    + "<br/><br/><center><font size=0.5em>Brought to you by gregorach</font></center>"
    newDiv.innerHTML = divHtml;
}

function GroupsBeta_Run() {
    // Add the kill file menu option to the menu bar
    var splitCh = String.fromCharCode(255);
    var list = new Array();
    data = unescape(GM_getValue("ThreadKillFile", "-----"));
    list = data.split(splitCh);

    // get thread title list
    var titleList = new Array();
    titleData = unescape(GM_getValue("ThreadTitleKillFile", "-----"));
    titleData = titleData.split(splitCh);

    var titleView = false;

    var cand = document.getElementById('navtabs');
    var candItem = cand.childNodes[cand.childNodes.length-2];
    if(candItem.childNodes.length == 1)
      candItem = cand.childNodes[cand.childNodes.length-4];
    var candList = candItem.childNodes[candItem.childNodes.length-2];

    var newLink = document.createElement('a');
    newLink.setAttribute('href', 'javascript:ManageThreadKillFile()');
    var linkText = document.createTextNode("Ignored Threads");

    var tdata = document.createElement('li');
    candList.appendChild(tdata);
    tdata.appendChild(newLink);
    newLink.appendChild(linkText);

    // Creat the div that will show all the folks on the killfile
    var newDiv = document.createElement("div");
    newDiv.id = "allfolks";
    var divHtml = "The Morgue";
    newDiv.innerHTML = divHtml;

    cand.parentNode.insertBefore(newDiv, cand.nextSibling);

    newDiv.style.position = "absolute";
    newDiv.style.top = "10px";
    newDiv.style.left = "10px";
    newDiv.style.backgroundColor = "#fff";
    newDiv.style.color = '#000';
    newDiv.style.fontSize = "12px";
    newDiv.style.fontFamily = "Verdana";
    newDiv.style.padding = "10px";
    newDiv.style.border = "solid 1px #000000";
    newDiv.style.visibility = "hidden";
    newDiv.id = "threadKillList";
    newDiv.style.zIndex = "300";
    newDiv.style.textAlign = 'left';
    updateKillFileText(list, titleData);

    GroupsBeta_Thread_List_View(list);
}

// Main routine
GM_log(location.href);
GroupsBeta_Run();
// End
 

forestwalker

Bushcrafter (boy, I've got a lot to say!)
What I would like -- for bulletin boards in general -- is a feature like the kill-file of dear old Usenet. Where I can decide that all posts by that w*nk*r Forestwalker is a waste of space and have them hidden so I'll never have to read them. Or to flag all posts/threads where Robin Wood and any of the words "wood", "axe" or "turning" is mentioned as interesting. That would help a lot. And of course hide all the Bear Gryllis related posts.
 

gregorach

Bushcrafter (boy, I've got a lot to say!)
Sep 15, 2005
3,723
28
50
Edinburgh
Actually, it was originally written to ignore users. I rewrote it because I wanted to be able to block specific threads without losing everything posted by a given user. I figure pretty much everybody on here has something useful to say occasionally... Fortunately, BCUK has no real trolls, thanks to the sterling efforts of our fine mods. I use the classic killfile script for various blogs, but I don't think it works here. I'm sure there's something out there somewhere though.
 

Grooveski

Native
Aug 9, 2005
1,707
10
53
Glasgow
The one Bigfoot mentioned in post 21 works a treat but not with vb4. Went over to bcl and watched the same user just vanish with two clicks of a mouse, it was glorious.
With vb4 forums it doesn't work and when I tried to add the details manually to it's ignore script all that happened was it added that user to my (forum based)ignore list. That doesn't really cut it as you still see their quotes and it only works when you're logged on.

I've trawled the net looking for others but could only find this. It's another oldie though and only works with an antique version of firefox. I found a copy of firefox 1.0 but it was so flaky I couldn't even get as far as adding a plugin.
https://addons.mozilla.org/en-US/firefox/addon/1045/

It's a nice sentiment that there are no trolls here but sometimes listening to a user post the same weary putdowns year after year can get irritating. I'd happily lose the odd useful thought if it made the forum a cheerier place. :)
 

telwebb

Settler
Aug 10, 2010
580
0
Somerset, UK
Hi gregorach - got it back now after a remove and replace operation :) Can't seem to do the same elsewhere though - is that because of different forum software do you think?
 

BCUK Shop

We have a a number of knives, T-Shirts and other items for sale.

SHOP HERE