d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Helpful Greasemonkey User Script
1235Next
Add Reply New Topic New Poll
Member
Posts: 6,953
Joined: Sep 27 2003
Gold: 518.50
Oct 18 2009 08:04pm
Here is a helpful Greasemonkey script that will make the Programmer's Haven a better place for you. It removes all posts by Muted and leaves a nice, blank space in their place to let you know that you are missing something.

Code
// ==UserScript==
// @name           Ignore Muted
// @namespace      http://asbands.d2jsp.org/
// @description    Ignores all posts made by Muted by making them invisible
// @include        http://forums.d2jsp.org/*
// ==/UserScript==
function takeoutPoster(posterName) {
   var posts = document.getElementsByTagName('fieldset').wrappedJSObject;
   for (var i = 0; i < posts.length; i++) {
       var post = posts.item(i);
       if (isPostedBy(post, posterName)) {
           post.style.visibility = 'collapse';
       }
   }
}

function isPostedBy(post, posterName) {
   var legend = post.firstChild;
   if (!legend) return false;
   else {
       var link = legend.firstChild;
       if (!link) return false;
       else if (link.innerHTML) {
           return (link.innerHTML == posterName);
       }
   }
}

takeoutPoster('Muted');
Member
Posts: 31,680
Joined: Nov 10 2007
Gold: 1.00
Oct 18 2009 08:06pm
Neat. :)

A perma-squelch for forums - I've only seen that on one other forum, it was extremely helpful too.

This post was edited by Muted on Oct 18 2009 08:08pm
Member
Posts: 11,637
Joined: Feb 2 2004
Gold: 434.84
Oct 18 2009 08:08pm
Quote (ASBands @ Sun, Oct 18 2009, 10:04pm)
Here is a helpful Greasemonkey script that will make the Programmer's Haven a better place for you.  It removes all posts by Muted and leaves a nice, blank space in their place to let you know that you are missing something.

Code
// ==UserScript==
// @name           Ignore Muted
// @namespace      http://asbands.d2jsp.org/
// @description    Ignores all posts made by Muted by making them invisible
// @include        http://forums.d2jsp.org/*
// ==/UserScript==
function takeoutPoster(posterName) {
   var posts = document.getElementsByTagName('fieldset').wrappedJSObject;
   for (var i = 0; i < posts.length; i++) {
       var post = posts.item(i);
       if (isPostedBy(post, posterName)) {
           post.style.visibility = 'collapse';
       }
   }
}

function isPostedBy(post, posterName) {
   var legend = post.firstChild;
   if (!legend) return false;
   else {
       var link = legend.firstChild;
       if (!link) return false;
       else if (link.innerHTML) {
           return (link.innerHTML == posterName);
       }
   }
}

takeoutPoster('Muted');


Using a programmer's ingenuity to fix a problem. I like it.
Member
Posts: 9,475
Joined: Mar 14 2005
Gold: 110.00
Oct 18 2009 08:08pm
I don't know GreaseMonkey or javascript that well but wouldn't a more complete solution be filtering by the userid in the url part? You never know, the user in question could change their name (but not their ID).
Member
Posts: 31,680
Joined: Nov 10 2007
Gold: 1.00
Oct 18 2009 08:09pm
Quote (llamaoo7 @ Sun, 18 Oct 2009, 21:08)
I don't know GreaseMonkey or javascript that well but wouldn't a more complete solution be filtering by the userid in the url part?  You never know, the user in question could change their name (but not their ID).


That's what google is for.
Also copy & paste.


Quote (rockonkenshin @ Sun, 18 Oct 2009, 21:08)
Using a programmer's ingenuity to fix a problem. I like it.


It doesn't fix any problems, only creates one: Removes the posts of a good poster.
To fix a problem would remove the posts of say, rockonkenshin and ASBands!

This post was edited by Muted on Oct 18 2009 08:10pm
Member
Posts: 6,953
Joined: Sep 27 2003
Gold: 518.50
Oct 18 2009 08:15pm
Quote (llamaoo7 @ Sun, Oct 18 2009, 09:08pm)
I don't know GreaseMonkey or javascript that well but wouldn't a more complete solution be filtering by the userid in the url part?  You never know, the user in question could change their name (but not their ID).

I didn't think that people were allowed to change their user name. In any case, if that happens then it is pretty easy to change the file or add more people to the list. ;)

This post was edited by ASBands on Oct 18 2009 08:18pm
Member
Posts: 11,637
Joined: Feb 2 2004
Gold: 434.84
Oct 18 2009 08:17pm
Quote (ASBands @ Sun, Oct 18 2009, 10:15pm)
I didn't think that people were allowed to change their user name.  In any case, if that happens then it is pretty easy to change the file ;)


Yeah, it's apparently a newish FG feature. It should be just as easy as grabbing the user profile url and stripping out everything after the last '='.
Member
Posts: 31,680
Joined: Nov 10 2007
Gold: 1.00
Oct 18 2009 08:20pm
Quote (rockonkenshin @ Sun, 18 Oct 2009, 21:17)
Yeah, it's apparently a newish FG feature. It should be just as easy as grabbing the user profile url and stripping out everything after the last '='.


Neat.
Member
Posts: 6,953
Joined: Sep 27 2003
Gold: 518.50
Oct 18 2009 08:23pm
Example usage:
Member
Posts: 9,475
Joined: Mar 14 2005
Gold: 110.00
Oct 18 2009 08:26pm
Hmm, I don't know if it was my browser but I had to make a couple of tweaks to get it to work. I've only tried to pick up on web programming the past week or so.

Code
// ==UserScript==
// @name           Ignore Muted
// @namespace      http://asbands.d2jsp.org/
// @description    Ignores all posts made by Muted by making them invisible
// @include        http://forums.d2jsp.org/*
// ==/UserScript==

function takeoutPoster(posterName) {
  var posts = document.getElementsByTagName('fieldset').wrappedJSObject;
  for (var i = 0; i < posts.length; i++) {
      var post = posts.item(i);
      if (isPostedBy(post, posterName)) {
          post.style.visibility = 'collapse';
      }
  }
}

function isPostedBy(post, posterName) {
  var legend = post.firstChild;
  if (!legend) return false;
  else {
      var link = legend.firstChild;
      if (!link) return false;
      else if (link.innerHTML) {
          return (rtrim(link.text) == posterName);
      }
  }
}

function rtrim(stringToTrim) {
return stringToTrim.replace(/\s+$/,"");
}


takeoutPoster('Muted');
Go Back To Programming & Development Topic List
1235Next
Add Reply New Topic New Poll