Page 1 of 2

There a way to extend 'ignore' to threads created too?

Posted: Tue May 05, 2015 2:37 am
by OgreBattle
So ignore is a fine and dandy feature of the Den, but while I can ignore posts made by people set to ignore, any new threads they create still show up.

Is there a way for the ignore feature to extended so threads created by ignored people don't show up?

Posted: Tue May 05, 2015 4:05 am
by erik
I've been looking into scripts that we can use via Greasemonkey plugin, but so far the scripts for flagging threads to be ignored (either by selecting threads, or automatically based upon a scripted ignore list) have been for other versions of vb software not applicable to our forum (or that I've yet to learn how to adapt to our forum). My search continues.

When I get time I'll teach myself how to write one up for the den but I'm traveling next weekend and have a fairly packed summer schedule already, so can't even offer a tentative estimate on completion date.

Posted: Tue May 05, 2015 6:12 am
by DSMatticus
This has been a requested feature before, and hey, I don't think I've done any javascript since... I was a freshman in college. So here's a greasemonkey plugin that AFAIK does that. EDIT: And by that, I mean hides any thread started by silva specifically. Sorry, forgot to mention that.

Code: Select all

// ==UserScript==
// @name        Ignore Silva Threads
// @namespace   http://www.tgdmb.com/profile.php?mode=viewprofile&u=1278
// @version     1.0
// @grant		none
// @include     http://www.tgdmb.com/*
// ==/UserScript==

var mslist = document.getElementsByTagName("a");

for &#40;var i = 0; i < mslist.length; i++&#41; &#123;
    var ms = mslist&#91;i&#93;;
    if &#40;ms.getAttribute&#40;"href"&#41; == "profile.php?mode=viewprofile&u=1768"&#41; &#123;
		if &#40;ms.parentNode.parentNode.getAttribute&#40;"class"&#41; == "row3"&#41; &#123;
			var ds = ms.parentNode.parentNode.parentNode;
			ds.parentNode.removeChild&#40;ds&#41;;
		&#125;
    &#125;
&#125;
If you have greasemonkey, you can just click "new user script" or whatever and copy paste this over top of it. The usual disclaimers apply - I take no responsibility for your computer exploding/your house catching fire/your spouse leaving you/your bank account being mysteriously emptied/global warming. All of those things are clearly your fault. Feel free to provide bug reports or feature requests or whatever.

EDIT: Repasted just to make sure I didn't copy-paste from an out-of-date window by accident.

Posted: Tue May 05, 2015 9:56 am
by Koumei
DSMatticus wrote:And by that, I mean hides any thread started by silva specifically.
I assure you it does everything it needs to do.

Posted: Tue May 05, 2015 11:15 pm
by erik
// @include http://tgdmb.com/*

I had to take out the "www." to get it to work (actually I just added it under preferences, but you know what I mean), but now it's workin' baby.

Thanks, DSM!

Posted: Wed May 06, 2015 12:30 am
by Dean
I consider this a bold new achievement for mankind

Posted: Wed May 06, 2015 6:31 pm
by Starmaker
I don't want to look thankless, but here's a bug report:

When the two most recent silva threads on a page are consecutive, the top of the two doesn't get ignored.

Experimental data:

Currently, there are two pairs of silva threads on the first page of IMHO, plus an assortment of loose threads (preceded and followed by nonsilva posters).
All the loose threads get ignored.
The second pair (down the page) gets ignored in full.
However, out of the first pair, comprising two most recent silva threads, the top thread is still displayed.

The same thing happens on the second page of IMHO: the most recent silva threads happen to be consecutive, and the first is still displayed. The second of the pair and all the loose threads vanish just fine.

There wasn't enough silva for an advanced falsification experiment (incredible, right?), so I found a page with a pair of consecutive threads by another poster which had a more recent loose thread by the same poster and changed the script to ignore them instead. It worked: the most recent loose thread, the pair down the page, and other loose threads vanished.

Posted: Wed May 06, 2015 8:16 pm
by DSMatticus
Solved, I think. Here's the new version:

Code: Select all

// ==UserScript==
// @name        Ignore Silva Threads
// @namespace   http&#58;//www.tgdmb.com/profile.php?mode=viewprofile&u=1278
// @version     1.02
// @grant		none
// @include     http&#58;//www.tgdmb.com/*
// ==/UserScript==

var mslist = document.getElementsByTagName&#40;"a"&#41;;

var i = 0;
while &#40;i < mslist.length&#41; &#123;
    var ms = mslist&#91;i&#93;;
	var increment = 1;
    if &#40;ms.parentNode.parentNode.getAttribute&#40;"class"&#41; == "row3"&#41; &#123;
		if &#40;ms.getAttribute&#40;"href"&#41; == "profile.php?mode=viewprofile&u=1768"&#41; &#123;
			var ds = ms.parentNode.parentNode.parentNode;
			ds.parentNode.removeChild&#40;ds&#41;;
			increment = 0;
		&#125;
    &#125;
	if &#40;increment == 1&#41; &#123;
		i++;
	&#125;
&#125;
Explanation for funsies: this script works by looping over every hyperlink on the page, and checking each to see if it is 1) the author field of the table, and 2) a hyperlink to silva's user profile. If so, it's a thread by silva and should be removed. The problem is that the list I was looping over was not the static derivative of the html source I thought it was. It was actually a live reflection of the html source. Removing elements from the html changed the position of every element after that on the list, which threw off the loop count and caused me to skip whatever was after a removed thread. Two silva threads back to back? The second hides in the shadow of the first. The whole story is slightly more complicated than that, because each table entry is actually multiple hyperlinks, but whatever.

The proper fix would have been to use a proper iterator, but I am too lazy to even google whether or not javascript provides iterators (am I being too mean to javascript here?). Instead I just switched to a while loop and increment only on not-removal, so if we remove something at position 3 we'll check position 3 again to see what new element "fell" into the slot. No more shadow.

Posted: Wed May 06, 2015 8:47 pm
by Pixels
You could also have reversed the order of your for loop. I.e.,

Code: Select all

...
for &#40;var i = mslist.length; i >= 0; i--&#41; &#123;
...

Posted: Wed May 06, 2015 9:33 pm
by DSMatticus
That's not completely safe in this instance. The loop runs on hyperlinks, but removes table entries. Table entries are composed of multiple hyperlinks, at least one of which (the thread title) comes before the author field. If the loop is at position i and decides to remove a table entry, it will (bare minimum, I haven't looked at the html source too closely) remove the list element at i (safe), i+1 (safe), and i-1 (dangerous).

You might consider decrementing by more than one, but I'm not sure the number of hyperlinks in each table entry is fixed (consider the hyperlinks to individual pages), and even if they were that would require aligning your loop with the table itself (there are a bunch of hyperlinks before and after the table) so you didn't end up decrement hopping between, say, the thread title instead of the author field.

Posted: Sat May 09, 2015 6:44 pm
by DSMatticus
I'm being dumb. Not incrementing on removal doesn't work for the same exact reasons I described above. If we find silva as an author at position i, we can (but won't always) remove enough elements from the list that the "next" author ends up at a position behind i. It's the same goddamn problem I just pointed out. Derp.

So while my last fix reduced the amount of skippage considerably, silva's latest thread has shown me that it still doesn't always work.

Code: Select all

// ==UserScript==
// @name        Ignore Silva Threads
// @namespace   http&#58;//www.tgdmb.com/profile.php?mode=viewprofile&u=1278
// @version     1.03
// @grant		none
// @include     http&#58;//www.tgdmb.com/*
// ==/UserScript==

var mslist = document.getElementsByTagName&#40;"a"&#41;;

for &#40;var i = 0; i < mslist.length; i ++&#41; &#123;
	var ms = mslist&#91;i&#93;;
    if &#40;ms.parentNode.parentNode.getAttribute&#40;"class"&#41; == "row3"&#41; &#123;
		if &#40;ms.getAttribute&#40;"href"&#41; == "profile.php?mode=viewprofile&u=1768"&#41; &#123;
			var ds = ms.parentNode.parentNode.parentNode;
			var oldLength = mslist.length;
			ds.parentNode.removeChild&#40;ds&#41;;
			var newLength = mslist.length;
			i = &#40;i - &#40;oldLength - newLength&#41;&#41; - 1;
			if &#40;i < 0&#41; &#123;
				i = 0;
			&#125;
		&#125;
    &#125;
&#125;
I think this version does it. It counts how many elements were removed and moves i back by that many steps. If that puts i below 0 (which is theoretically possible; the number of list elements isn't contrained by i because a table entry can contain some unknown number of list elements in front of i) it gets set to 0 instead.

Posted: Tue Jun 02, 2015 6:59 am
by OgreBattle
So does the latest thing DSMatticus posted work?

Posted: Tue Jun 02, 2015 8:49 am
by DSMatticus
I've been using it since I posted it and I haven't seen any bugs. The problems with the earlier versions weren't particularly complicated or crippling; the documentation I was using didn't feel like mentioning that getElementsByTagName returned a live list, which would have been really nice to know. My first attempt to account for that had a simple counting error, in that it needed to count things and it didn't.

If you're the sort of dirty heathen who types addresses into the address bar without the www (like erik), you might need to configure the script in greasemonkey to also include "http://tgdmb.com". Greasemonkey > manage user scripts > options on the script you want. If you browse tgdmb using https (... does that even do anything? Does tgdmb even support that?), you'll have to do something similar.

Posted: Mon Jun 08, 2015 8:24 pm
by nockermensch
DSM, another strategy that works in this situation is to do the loop twice.

For the first pass you just mark all the elements you want to delete (add the class "delete-me" to them, for example).

For the second pass your code can be just:

var silvaThreads = document.getElementsByClassName("delete-me");
while(silvaThreads.length > 0) {
var silvaThread = silvaThreads.pop();
silvaThread.parentNode.removeChild(silvaThread);
}

The resulting code is much cleaner to read and you don't have to worry about skipping threads.

Posted: Fri Jun 12, 2015 7:46 am
by OgreBattle
Does that greasemonkey plugin work on tampermonkey for chrome?

Posted: Fri Jun 12, 2015 3:27 pm
by nockermensch
OgreBattle wrote:Does that greasemonkey plugin work on tampermonkey for chrome?

Code: Select all

// ==UserScript==
// @name         unsilvator
// @namespace    http&#58;//your.homepage/
// @version      0.1
// @description  based on DSM's great idea
// @author       nockermensch
// @match        http&#58;//www.tgdmb.com/*
// @grant        none
// ==/UserScript==

var authors = document.querySelectorAll&#40;'.row3'&#41;;
var silvaThreads = &#91;&#93;;
for&#40;var i = 0; i<authors.length; i++&#41; &#123;
    var author = authors&#91;i&#93;;
    if&#40;author.firstChild.firstChild.href.indexOf&#40;"profile.php?mode=viewprofile&u=1768"&#41; > 0&#41; &#123;
        silvaThreads.push&#40;author&#41;;
    &#125;
&#125;
while&#40;silvaThreads.length > 0&#41; &#123;
    var silvaThread = silvaThreads.pop&#40;&#41;;
    silvaThread.parentNode.parentNode.removeChild&#40;silvaThread.parentNode&#41;;
&#125;
As it happens, I'm a chrome user too.

Posted: Mon Jul 06, 2015 2:12 am
by Krusk
I love that this thread is a thing

Posted: Sat Jul 11, 2015 10:03 pm
by TiaC
So, is there any good reason not to add "silva keep out" to every thread?

Posted: Sat Jul 11, 2015 10:15 pm
by Username17
TiaC wrote:So, is there any good reason not to add "silva keep out" to every thread?
There's a character limit to thread titles.

-Username17

Posted: Sat Jul 11, 2015 10:28 pm
by Kaelik
FrankTrollman wrote:
TiaC wrote:So, is there any good reason not to add "silva keep out" to every thread?
There's a character limit to thread titles.

-Username17
Also, if we were all in such agreement (as we fucking should be) then we should just ban him. If everyone is ignoring all silva threads and asking silva to stay out of their threads, then instead of having newbies painfully learn the terror of silva over and over, and having his name everywhere on the sight, we could just ban him.

I mean, he don't have Elennsar stay out in every thread title.

Posted: Mon Jul 13, 2015 6:53 pm
by nockermensch
Kaelik wrote:
FrankTrollman wrote:
TiaC wrote:So, is there any good reason not to add "silva keep out" to every thread?
There's a character limit to thread titles.

-Username17
Also, if we were all in such agreement (as we fucking should be) then we should just ban him. If everyone is ignoring all silva threads and asking silva to stay out of their threads, then instead of having newbies painfully learn the terror of silva over and over, and having his name everywhere on the sight, we could just ban him.

I mean, he don't have Elennsar stay out in every thread title.
Well, there's this: http://www.tgdmb.com/viewtopic.php?t=56135

I don't want to keep bringing your attentions to my avatar picture, but it's fucking >2015 and people here keep talking to the troll.

Posted: Mon Jul 13, 2015 9:33 pm
by Kaelik
nockermensch wrote:
Kaelik wrote:
FrankTrollman wrote:
There's a character limit to thread titles.

-Username17
Also, if we were all in such agreement (as we fucking should be) then we should just ban him. If everyone is ignoring all silva threads and asking silva to stay out of their threads, then instead of having newbies painfully learn the terror of silva over and over, and having his name everywhere on the sight, we could just ban him.

I mean, he don't have Elennsar stay out in every thread title.
Well, there's this: http://www.tgdmb.com/viewtopic.php?t=56135

I don't want to keep bringing your attentions to my avatar picture, but it's fucking >2015 and people here keep talking to the troll.
I know we aren't all in agreement, which is why I said should instead.

Posted: Mon Jul 20, 2015 5:27 am
by OgreBattle
nockermensch wrote:
OgreBattle wrote:Does that greasemonkey plugin work on tampermonkey for chrome?

Code: Select all

// ==UserScript==
// @name         unsilvator
// @namespace    http&#58;//your.homepage/
// @version      0.1
// @description  based on DSM's great idea
// @author       nockermensch
// @match        http&#58;//www.tgdmb.com/*
// @grant        none
// ==/UserScript==

var authors = document.querySelectorAll&#40;'.row3'&#41;;
var silvaThreads = &#91;&#93;;
for&#40;var i = 0; i<authors.length; i++&#41; &#123;
    var author = authors&#91;i&#93;;
    if&#40;author.firstChild.firstChild.href.indexOf&#40;"profile.php?mode=viewprofile&u=1768"&#41; > 0&#41; &#123;
        silvaThreads.push&#40;author&#41;;
    &#125;
&#125;
while&#40;silvaThreads.length > 0&#41; &#123;
    var silvaThread = silvaThreads.pop&#40;&#41;;
    silvaThread.parentNode.parentNode.removeChild&#40;silvaThread.parentNode&#41;;
&#125;
As it happens, I'm a chrome user too.
I've copy/pasted that into TamperMonkey's "Add New Script" option, hit "save", and it doesn't seem to work. Am I missing a step?

Posted: Wed Jul 22, 2015 7:31 pm
by nockermensch
OgreBattle wrote: I've copy/pasted that into TamperMonkey's "Add New Script" option, hit "save", and it doesn't seem to work. Am I missing a step?
With the script installed, do you see a "1" or "2" next to the tampermonkey icon when you browse The Gaming Den? If you do, it means the script is working. I just tested it on a fresh tampermonkey install, and it works.

Posted: Wed Jul 22, 2015 7:54 pm
by DSMatticus

Code: Select all

// @match        http&#58;//www.tgdmb.com/*
For FireFox's greasemonkey, each of the following four items is a separate address:

Code: Select all

http&#58;//www.tgdmb.com/*
http&#58;//tgdmb.com/*
https&#58;//www.tgdmb.com/*
https&#58;//tgdmb.com/*
I assume Chrome's TamperMonkey works the same way. If that is the problem, you can either adjust the script (or plugin settings) to match the way you access TGD or change the way you access TGD to match the script.

Erik had the same problem with my script upthread, because he is a dirty heathen.