Any Greasemonkey scripters in the house?

Tonight in IRC we were bemoaning the lack of an ignore feature on the forums. I figured it would be possible to knock up a Greasemonkey script to inspect the DOM and strip out comments from a known list of offenders.

I did a quick View Source of a thread and extracted a single comment from the HTML. It looks like this.

Things to note:

  • Each comment is in either a <div class="comment even "> or a <div class="comment odd ">.
  • Inside this div is a <div class="author">, and inside that, <div class="author-name">.
  • The "author-name" div has exactly one element, which is the name of the poster inside a link to their user profile.

So I guess that in order to strip out someone's posts, you'd just need to search through all the <div class="author-name"> elements in the DOM, and then remove the grandparent-div from any that you find. (Pedantry: this would muck up the different coloured backgrounds between alternate posts, but who actually cares.)

Now this is the point where I weasel out of doing it myself, using the excuse that I'm not familiar enough with web development and Greasemonkey scripting. Would any one of you lovely people be kind enough to do the forum a favour and knock a script up using these details?

Don't hate me because I'm beautiful.

[Edit] This script was written prior to the new GWJ, and I never used it so I don't know if it still works or not. If it doesn't then I just give you an oogaba-delivered (?) message:

IMAGE(http://rlv.zcache.com/cant_we_all_just_get_along_tshirt-p235582974936870443a6rj9_400.jpg)

You can also hide P&C entirely, if that's the primary source of your consternation.

LiquidMantis wrote:

Don't hate me because I'm beautiful.

[Edit] This script was written prior to the new GWJ, and I never used it so I don't know if it still works or not.

Having had a quick look at the code, I suspect it won't But it's possibly a good starting point, so thanks.

I might knock something up today. Last night I put on my fedora hat and rope, and went exploring the ancient jungles of my JS/HTML knowledge. I still think it should be fairly easy...

Heh.... i find it sad that people want to put people on ignore here. One of the things i like about forums is that you can see dissenting opinions and choose to not read them. The onus is on you as long as those people aren't posting pictures of deviant sexual acts etc. (which you can't always unsee :)).

Then again, there are people who might post one or a short series of inflammatory comments that may make you want to put them on block but later on they will provide insight and interesting angles on a topic that you'd otherwise miss. I can think of a few people like this off the top of my head....

You start blocking one person.... then another few.... after a while you're visiting the site to look at white space.

If you're on firefox with the GM extension, get the greasefire extension too which will highlight whenever there's scripts available for the current site you're browsing.

Duoae wrote:

Heh.... i find it sad that people want to put people on ignore here...there are people who might post one or a short series of inflammatory comments that may make you want to put them on block but later on they will provide insight and interesting angles on a topic that you'd otherwise miss.

Blocking is merely a tool; whether you use it for good or evil is up to you. And it's not like it's going to affect the experience of anyone other than you, so the only harm it's going to do is to yourself.

And of course, there's nothing to stop you unblocking people you've previously blocked.

Scratched wrote:

If you're on firefox with the GM extension, get the greasefire extension too which will highlight whenever there's scripts available for the current site you're browsing.

Is this general info, or are you suggesting that the script already exists?

Floomi wrote:

Blocking is merely a tool; whether you use it for good or evil is up to you. And it's not like it's going to affect the experience of anyone other than you, so the only harm it's going to do is to yourself.

And of course, there's nothing to stop you unblocking people you've previously blocked.

That's not true at all. You're directly affecting the experience of everyone else on the site either through not reading the all posts in a thread so you repost redundant information or conflicting and previously dismissed 'truths' or facts.

Say i and three other people blocked Scratched there and the other three people had blocked me and each other.... You could end up with the situation of up to five people posting about the GM extension in firefox.

Alternatively you could miss out on important information - say you'd blocked Scratched - and you'd not know about the GM extension in firefox if no one else posted it.

Of course, as you point out, you could unblock people at any time. I just don't see the type of person who blocks someone due to a post or difference in opinion unblocking them due to a post they couldn't read. The psychology of a person who blocks someone for some past difference or stance would not mesh with someone who's giving them a second chance. The point being, if you're just going to unblock them any time they post something that you might want to read - why block them at all? Especially since you have no way of telling how much a particular post is 'worth'.

If I post duplicate information, I get coughed and look/feel like a pillock.

If I miss out on information because I've blocked someone - well, that's my loss.

If it gets to the stage that I end up blocking a large number of posts on the forums, then evidently this community isn't right for me, and I should leave. But I don't see why I should let one or two posters sour the otherwise positive experience by forcing myself to read through (or otherwise scroll past) their posts.

There's also nothing stopping me modifying the script so that it only blocks people within a certain set of threads. That way I can strip out elements of a discussion I'm not interested in, while still being able to see posts by that person in other threads.

Really, I don't think there's much difference between scrolling past someone's posts and blocking them altogether, other than the amount of scrolling you have to do.

I actually wrote a Firefox extension called baNdit that allows you to ignore users on another site I frequent, and one of the main features is ignoring other users. The basic code, if you use jQuery is just:

$("div.author-name:contains('" + username + "')".parent("div.comment").hide();

Find a way to store/edit ignored users, and loop through the list every time the page loads, calling that line for each user. Ignoring replies to that user is more difficult, since people might not use quote tags.

If you don't mind editing the script yourself, you could just cut and paste lines, changing only the username, like:

$("div.author-name:contains('Floomi')".parent("div.comment").hide();
$("div.author-name:contains('Bonus_Eruptus')".parent("div.comment").hide();
$("div.author-name:contains('Scratched')".parent("div.comment").hide();

No looping or storage required.

Floomi wrote:
Scratched wrote:

If you're on firefox with the GM extension, get the greasefire extension too which will highlight whenever there's scripts available for the current site you're browsing.

Is this general info, or are you suggesting that the script already exists?

General info, it's a good addon for finding ways to make your favourite websites easier on the eye.

As for user ignoring, I suspect the same thing could be done through Adblock with a rule like "gamerswithjobs.com##DIV.nametoignore"
edit: that filter doesn't quite work

Here you go, Floomi:

Ignore Goodjers script

Download it, save it as ignore_goodjers.user.js, then drag-and-drop onto Firefox. You and I are ignored by default, and you have to go into "Manage User Scripts" to edit it. Just add/remove names from the usersToIgnore array, and reload the page, and it should replace all of their comments with "Did $username Tannhauser me?" links that will restore the comments.

Biggest problem with my earlier code was that you can't access div.comment with jQuery because it chokes on newlines in the class name, which GWJ inserts for some reason. I had to clean them up a bit on loading the page.

Donations in the form of video games are welcome.

Beautiful work, works a charm for me. And far more elegant code than I'd have written...

Cool! Now I can block Duoae.

Floomi wrote:

And then it worked for me. Now I don't have to put up with Duoae's self-righteous "everyone's comments are equally important" comments any more ;)

Internet high-five!

Did Stone say something? Guys? What did Stone say?

IMAGE(http://rps.net/QS/Images/Smilies/sad.gif)

Quintin_Stone wrote:

Cool! Now I can block Duoae.

Hey, I just did that!

For anyone using Opera: I had to do a little fiddling to get it to work. Opera doesn't seem to parse the @require line, so you have to go get the JQuery script yourself:

  • Create a user scripts folder somewhere (I put mine in the Program Files\Opera directory) and tell Opera where to look for it. You should do this in the site preferences for this site only, the option for which is in Tools -> Quick Preferences -> Edit Site Preferences -> Scripting.
  • Copy and paste the script into that folder.
  • Open it, and paste the full address of the file in the @require line of the UserScript section into your address bar.
  • Save that file, rename it to 0-jquery.js, and put that in your user scripts folder too. The rename ensures it gets loaded before the GWJ block script, which is what we need.

And then it worked for me. Now I don't have to put up with Duoae's self-righteous "everyone's comments are equally important" comments any more

edit:\ I found that enabling these scripts globally resulted in odd behaviour on other sites, namely Facebook (comment buttons had disappeared). I assume this has something to do with conflicting implementations of JQuery, so I've updated the instructions above to use custom scripts for only this site. You'll have to make a separate folder for each site if you want to use different scripts for different sites.

*puts everyone on ignore, blathers away in the silence*

Speaking of Greasemonkey, is anyone nice enough to whip together something to hide certain threads in the tracker? Things you commented in two years ago, but no longer care about, that sort of thing?

DF7 wrote:

Speaking of Greasemonkey, is anyone nice enough to whip together something to hide certain threads in the tracker? Things you commented in two years ago, but no longer care about, that sort of thing?

It's "Write jQuery stuff for Goodjers day" for me today, so I'll whip something up in a bit.

Bonus_Eruptus wrote:
DF7 wrote:

Speaking of Greasemonkey, is anyone nice enough to whip together something to hide certain threads in the tracker? Things you commented in two years ago, but no longer care about, that sort of thing?

It's "Write jQuery stuff for Goodjers day" for me today, so I'll whip something up in a bit.

Thanks! It will probably save me a lot of money, since I want to hide the deal thread.

DF7 wrote:
Bonus_Eruptus wrote:
DF7 wrote:

Speaking of Greasemonkey, is anyone nice enough to whip together something to hide certain threads in the tracker? Things you commented in two years ago, but no longer care about, that sort of thing?

It's "Write jQuery stuff for Goodjers day" for me today, so I'll whip something up in a bit.

Thanks! It will probably save me a lot of money, since I want to hide the deal thread.

Quick and dirty script that took about an hour. Probably has bugs in it, but let me know if this is what you were looking for.

Ignore Tracked Threads

It'll work on your personal tracker and the main tracker. Looks like GM's wildcard system isn't as robust as I'd like. Either way, have fun.

I'm too stupid, how do I get this running?

First, install the Firefox Greasemonkey add-on.

Quintin_Stone wrote:

First, install the Firefox Greasemonkey add-on.

Second, download it as a file, then drag and drop onto Firefox.

Then load your tracker.

Ok, but then nothing is different? How do I add threads to ignore? I think the script is running but I don't see a difference.

how did i get here i am not good with piano halp

DF7 wrote:

Ok, but then nothing is different? How do I add threads to ignore? I think the script is running but I don't see a difference.

how did i get here i am not good with piano halp

I think it could be a problem with the tracker page URL. Which one are you using?

http://www.gamerswithjobs.com/user/8... OR
http://www.gamerswithjobs.com/tracke...

It's currently set up to only be included on the second format. Right-click the GM icon, manage the script, and add the following to the "Includes" section for that script:

http://www.gamerswithjobs.com/user/*...

That'll add it to that page, if you go through your profile and click the track tab. Didn't know it was a different URL format. After that, you should see "Ignore Thread" under thread titles in your tracker. Clicking those will ignore that thread and hide it. You can redisplay the hidden stories on the page if you want to unignore anything.

I am using the second format. I must have added it incorrectly.

Can someone write a GM script to prevent Google News from forcing the underlining of links? I would appreciate it.

Can someone write a greasemonkey script that will make me taller, more attractive and also richer? You can do that with jQuery right? There is a function that will let it use the MyLife API right?