• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Greasemonkey script for blocking posters' avatars

Status
Not open for further replies.

tokkun

Member
rhfb said:
You could easily block all avatars that end with .gif, but the thing is I'm assuming you want to block all ANIMATED gifs and not all gifs. gifs can be static too, and I don't think there is an easy way to detect if a gif is static or animated.

Loss of static gifs would be acceptable collateral damage.
 

Chris R

Member
tokkun said:
Loss of static gifs would be acceptable collateral damage.
Your wish is my command!

Code:
function execJQuery() {
	$("img[src$='.gif']").css('display', 'none');
}

Make sure to whitelist (no clue how to do this though in GM) the posting page if you use the icons to post things as they are all gifs and no longer visible as I type this :lol

edit: Unless you were just meaning to block all .gif avatars, in that case give me a few more mins to cook something up. This just blocks all .gif files all together, not caring where or what they are.
 

Chris R

Member
Plywood said:
It's so easy to skip someone's post when they don't have an avatar.

rhfb get an avatar!
Nooooooooooooooooo! Never!
I have one I could use but someone else had it already... and Chelsea just plain sucks this year :(

Code:
function execJQuery() {
	$(".smallfont").find("img[src$='.gif']").each(function (i) {
		$("img[src='" + this.src + "']").css('display', 'none');
	});
}

That blocks just the .gif avatars. Check back in a few more mins for an update that would block quoted avatars (again, as long as the quoted user has posted on that page)

edit: Updated, tested and it works on this page. Don't blame me if it doesn't work for you or breaks something else :p Like I said earlier I'm still learning this stuff.
 

hateradio

The Most Dangerous Yes Man
Why the hell are you kids using jQuery? Learn some damn (basic) JS.

http://userscripts.org/scripts/show/93896

Code:
// ==UserScript==
// @name           NeoGAF - Block Individual User Avatars
// @namespace      http://hateradio.co.cc/
// @include        http://www.neogaf.com/forum/showthread.php*
// @author         hateradio
// @version        1.0
// ==/UserScript==

var im = document.getElementById('posts').getElementsByTagName('img');

// Add users to the following list. Separate names by the pipe "|" character.
// This is case sensitive for precision.
var users = /User1|User2|User3/;

for(i = 0; i < im.length; i++){
	if(im[i].getAttribute('alt') && users.test(im[i].getAttribute('alt'))){
		im[i].setAttribute('style','display:none');
	}
}
 

AlteredBeast

Fork 'em, Sparky!
where the hell do I put this script in? I am not a coding expert and have no clue how to do this. This will make browsing at work doable and at home less embarrassing. Some of the avatars on here are obscene and lewd.
 

thetrin

Hail, peons, for I have come as ambassador from the great and bountiful Blueberry Butt Explosion
I honestly don't get the hate for anime avatars. Gory or gross ones on the other hand, I don't mind blocking.
 

hateradio

The Most Dangerous Yes Man
AlteredBeast said:
where the hell do I put this script in? I am not a coding expert and have no clue how to do this. This will make browsing at work doable and at home less embarrassing. Some of the avatars on here are obscene and lewd.
Which browser do you use? If you user Firefox you'll need the Greasemonkey add-on. Once it's installed you can go to the userscripts.org links and install them. To edit the JS you'll need something like Notepad, and add the names you don't want.
 

yencid

Member
Unless i know a user (Mostly from Creepy Gaf, HispaniGaf and a few other places) the way i recognize users is by their avatars a lot of times (and their tag) Why would i block them? >.<
 

KevinCow

Banned
Diablos said:
What is so terrible about avatars?

Because some people think this is a good avatar:

4ak56.gif
 

Doodis

Member
_dementia said:
Same but on Firefox. Great for work browsing.
Stupid question - but how do you do this in Firefox? I'm always getting weird glances at avatars on my screen at work. If it was just type, I wouldn't be scared to have GAF on my screen so much.
 

wolfmat

Confirmed Asshole
hateradio said:
Why the hell are you kids using jQuery? Learn some damn (basic) JS.
First of all, nice script.

I'm not a kid, and I know more than just basic JS. Fought with Ajax in numerous frameworks, for instance; cooked up asynchronous persistent dynamic forms and all that shit.

People tend to use jQuery when they really just invest like 2 minutes to sift through Firebug to get to some point, then traverse up the tree. It gets immediate results. Your solution is much cleaner though, so kudos.
 

Plywood

NeoGAF's smiling token!
hateradio said:
No, I meant for UserScripts.
Oh, then I don't know.

Supposedly this trick works: http://stackoverflow.com/questions/2648042/using-jquery-within-a-opera-user-javascript

down vote
Just for completeness:

I use it regularly with my userJS. Just copy your jquery.js into your userJS folder.

OptION 1 to keep it from conflicting with available jquery, use the noConflict option within the jqueryfile and associate jQuery with with your own identifier (jQueryMyIdentifier = jQuery; jQuery = null;) . your JS code can be wrapped with

(function($) {

// normal jquery js based on, jQueryMyIdentifier $('#bla').x();

})(jQueryMyIdentifier);

OPTION 2 check out, how to include a remote js using javascript. implement that include line into your JS. include "http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" or alike.

Doesn't work for me though.

Then again I don't even know where to put that code the person posted.
 

hateradio

The Most Dangerous Yes Man
^Yeah, I don't know either. I tend to stay away from @require when I make userscripts for cross-browser support.

wmat said:
First of all, nice script.

I'm not a kid, and I know more than just basic JS. Fought with Ajax in numerous frameworks, for instance; cooked up asynchronous persistent dynamic forms and all that shit.

People tend to use jQuery when they really just invest like 2 minutes to sift through Firebug to get to some point, then traverse up the tree. It gets immediate results. Your solution is much cleaner though, so kudos.
I know, but you're still using a framework to do something that can be done in a few lines of code; you don't need to call a 70KB script which will only be used to hide avatars. :lol
 

wolfmat

Confirmed Asshole
Plywood said:
Then again I don't even know where to put that code the person posted.
— Install Greasemonkey
— Right-click the ape face that appears, choose "New Userscript…"
— Enter appropriate unique data for identifying the script; the sites to apply it to are http://www.neogaf.com/forum/*
http://neogaf.com/forum*
(with the linebreak)
— A notepad window appears, paste code, modify to block specific avatars, save
— Done; reload site for testing

hateradio said:
I know, but you're still using a framework to do something that can be done in a few lines of code; you don't need to call a 70KB script which will only be used to hide avatars. :lol
Well, as you know, the point where you have to start with these things is some unique property somewhere around the element to block so that you either identify said element or some element in its branch. I had trouble finding a unique property immediately that was guaranteed to be in the avatar branch, so I just went the dumbfuck route. You're still right, of course.
 

malsumis

Member
hateradio said:
Does Opera even allow the include of jQuery? That may be the problem. I'm sure it can be done w/o jQuery and straightforward JavaScript.
Even if it does not( as I've never written a single UserJS ) you could always write to document a script tag and include jquery that way.

Plywood said:
Opera does have jQuery support afaik, they even had an article on it back in 07': http://dev.opera.com/articles/view/jquery-write-less-do-more/

and a more recent one:

http://dev.opera.com/articles/view/custom-html5-video-player-with-css3-and-jquery/

And for the love of god. It's always the other way around.
 

Plywood

NeoGAF's smiling token!
wmat said:
— Install Greasemonkey
— Right-click the ape face that appears, choose "New Userscript…"
— Enter appropriate unique data for identifying the script; the sites to apply it to are http://www.neogaf.com/forum/*
http://neogaf.com/forum*
(with the linebreak)
— A notepad window appears, paste code, modify to block specific avatars, save
— Done; reload site for testing
Well... I'm using Opera and I was inquiring about the User Highlighter, I feel bad now cause I jacked your thread with my issue. :(
malsumis said:
Even if it does not( as I've never written a single UserJS ) you could always write to document a script tag and include jquery that way.
How do I what now?
 

hateradio

The Most Dangerous Yes Man
malsumis said:
Even if it does not( as I've never written a single UserJS ) you could always write to document a script tag and include jquery that way.
I believe that's what the Highlighter script is actually doing. :p

Code:
var GM_JQ = document.createElement('script');
GM_JQ.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js';
GM_JQ.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(GM_JQ);
 

malsumis

Member
Code:
// ==UserScript==
// @name           NeoGAF Avatar Blocker
// @namespace      wmat
// @description    Block disgusting avatars on GAF
// @include        http://www.neogaf.com/forum/*
// @include        http://neogaf.com/forum*
// ==/UserScript==

if (window.opera) {
unsafeWindow=window;
}

var usernames   = new Array("Wraith", "RazieL", "wmat"); // <-- The blocked guys' names


var GM_JQ = document.createElement('script');
GM_JQ.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js';
GM_JQ.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(GM_JQ);


function GM_wait()
{


if(typeof unsafeWindow.jQuery == 'undefined') { window.setTimeout(GM_wait,100); }
    else { $ = unsafeWindow.jQuery; if(usernames.length > 0) execJQuery(); }
}

    
GM_wait();

function execJQuery()
	{
		for (var i=0; i < usernames.length; i++){
			$("a[class='bigusername']:contains('" + usernames[i] + "')").css('color', 'black').parent().parent().children().children().children("img").css('display', 'none');
		}	
}

should be both-compatible now.

PS: for Opera users I really recommend the Unite UserJS manager: http://unite.opera.com/application/401/


PS2:

as an added bonus for Opera compatibility-age I've also added

if (window.opera) {
unsafeWindow = window;
}

(which is really the only thing that I've done to both scripts :p)

to neogaf post highlighter script.

Code:
// ==UserScript==
// @name           NeoGAF User Highlighter
// @namespace      com.zombie.net
// @description    Highlight user posts, quotes, and threads.
// @include        http://www.neogaf.com/forum/*
// @include        http://neogaf.com/forum*
// 
// ==/UserScript==

// These two variables must be set!
//////////////////////////////////
var username   = "malsumis"; // <-- Your GAF username goes between the quotes.
var color      = '#d6e9cc'; // <-- This is the highlight color.

// Options
//////////////////////////////////
var highlight_avatar_area = true;
var highlight_post_area   = true;
var highlight_threads     = true;
var highlight_quotes      = true;
//////////////////////////////////
//
//
//
//
//
//
//
//
//
//
//
//
//
//

// Add jQuery
///////////////////////////////////////////////
var GM_JQ = document.createElement('script');
GM_JQ.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js';
GM_JQ.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(GM_JQ);

if (window.opera) {
unsafeWindow = window;
}

// Check if jQuery's loaded
function GM_wait()
{
	if(typeof unsafeWindow.jQuery == 'undefined') { window.setTimeout(GM_wait,100); }
    else { $ = unsafeWindow.jQuery; if(username.length > 0) execJQuery(); }
}
    
GM_wait();

// Execute
////////////////////////////////////////////////
function execJQuery()
{
	// just because
	$('.vbmenu_control').css('font-family', 'Arial');

	if(highlight_avatar_area && highlight_post_area)
		$("a[class='bigusername']:contains('" + username + "')").css('color', 'black').parent().parent().parent().children().css('background-color', '' + color + '');
	else
	{
		if(highlight_avatar_area)
			$("a[class='bigusername']:contains('" + username + "')").css('color', 'black').parent().parent().css('background-color', '' + color + '');
			
		if(highlight_post_area)
			$("a[class='bigusername']:contains('" + username + "')").css('color', 'black').parent().parent().siblings().css('background-color', '' + color + '');	
	}
		
	if(highlight_quotes)
	{
		$('div[id^="post_message"] > div > div').find(":contains(" + username +  ")").each(function(){
	 		$(this).parent().parent().find('td.quotearea').css('background-color', '' + color + '');
		});
	}
	
	if(highlight_threads)
	{
		$('table[id="threadslist"] > tbody > tr > td.alt2 a:contains("'  + username +  '")').each(function() {
			$(this).parent().css('background-color', '' + color + '').siblings().css('background-color', '' + color + '');
		});
	
		// subscription list
		$('form > table > tbody > tr > td.alt2 a:contains("'  + username +  '")').each(function() {
			$(this).parent().css('background-color', '' + color + '').siblings().css('background-color', '' + color + '');
		});
	}
	// $('tbody tr > td[id="td_title_3xxxxx"]').parent().hide();
}
 

tokkun

Member
rhfb said:
That blocks just the .gif avatars. Check back in a few more mins for an update that would block quoted avatars (again, as long as the quoted user has posted on that page)

edit: Updated, tested and it works on this page. Don't blame me if it doesn't work for you or breaks something else :p Like I said earlier I'm still learning this stuff.

Perfect. Thank you.
 

The Technomancer

card-carrying scientician
Do people honestly pay enough attention to avatars that it bothers them? I barely even see them, they're just useful for about thirty or so people on GAF whos posting trends I tend to overlap with; I see the avatar out of the corner of my eye and associate it with AceBandage or Drkirby, or whoever.
 

Threi

notag
I'm not one to use an anime avatar or even defend it, but I find it hilarious when someone expresses their hate for it while having a master chief/sackboy/nathan drake/marcus fenix avatar. The irony kills me :lol
 
yencid said:
Unless i know a user (Mostly from Creepy Gaf, HispaniGaf and a few other places) the way i recognize users is by their avatars a lot of times (and their tag) Why would i block them? >.<

Exactly. People are being bitches up in here, real talk.
 

yencid

Member
The_Technomancer said:
Do people honestly pay enough attention to avatars that it bothers them? I barely even see them, they're just useful for about thirty or so people on GAF whos posting trends I tend to overlap with; I see the avatar out of the corner of my eye and associate it with AceBandage or Drkirby, or whoever.
I dont pay enough attention for them to bother me. I do enjoy seeing a good avatar though, always nice.
 
yencid said:
Unless i know a user (Mostly from Creepy Gaf, HispaniGaf and a few other places) the way i recognize users is by their avatars a lot of times (and their tag) Why would i block them? >.<


So I can browse GAF at work and have it look like something that could be related to my work when people pass by and glance at my screen. :lol

Thanks for the scripts.
 

malsumis

Member
Plywood said:
...

I love you.

Seriously though, much appreciated.

edit: Is there a way to add multiple users?

For the avatar hide script just edit this line:

Code:
var usernames   = new Array("Wraith", "RazieL", "wmat"); // <-- The blocked guys' names

Add usernames in double quotes and with a comma (,) inbetween. The other script needs some more alteration.
 

Scrow

Still Tagged Accordingly
you'd have to be soulless to block my avatar. just look at that happy-go-lucky puppy! so full of exuberance and zest, how could you deny yourself that? :D
 
Status
Not open for further replies.
Top Bottom