IMPORTANT - Read before using...
This script is not meant to be a solution for bad behavior on Stack Exchange sites. If you feel somebody is violating the rules of this site, please contact the team via the "contact" link.
Update (Jan 19, 2023):
A user in the comments requested an updated version. Here's an approach which masks comments belonging to specified user IDs:
(function() {
'use strict';
const ids = [-1, 284996, 216691];
const selector = ids.map(( id ) => `[data-comment-owner-id="${id}"]`);
const styles = `
${selector.map( s => `${s} .comment-copy > *`)} {
color: transparent;
background: rgba(0, 0, 0, 0.15);
}
`;
document.head.appendChild(
document.createElement("style")
).innerHTML = styles;
function maskComments () {
document.querySelectorAll(selector.join(',')).forEach(createMask);
}
function createMask ( element ) {
const commentCopy = element.querySelector(".comment-copy");
for ( const child of commentCopy.childNodes ) {
if ( child.nodeName === "#text" && child.nodeValue !== " " ) {
const fragment = document.createDocumentFragment();
for ( const token of child.nodeValue.split(" ") ) {
const span = document.createElement("span");
span.textContent = token;
fragment.append(span, " ");
}
commentCopy.replaceChild( fragment, child );
}
}
}
maskComments();
})();
This approach preserves the actual comments (which can be revealed via selection) while masking their content. Here's an example:
Remove any instance of a particular user or group of users from your Stack Overflow experience with this Greasemonkey script. Just place their names in the userids array
and listen as the noise decreases.
Updates:
Tuesday, July 14, 2009
The script would remove any questions that were edited by anybody within your ignore-users list. This has been fixed. Additionally, avatars representing your ignored-users will be replaced with random avatars. Any remaining references to any names in your ignore-list will be replaced with 'unknown (Google),' a common title for unrecognizable users on Stack Overflow. Script was not operating properly on community-wiki posts.
Submit your improvements...
var userids = ['Username 1', 'Username 2'];
(function() {
function GM_wait() {
if(typeof unsafeWindow.jQuery == 'undefined') {
window.setTimeout(GM_wait,100);
}
else {
$ = unsafeWindow.jQuery; letsJQuery();
}
}
GM_wait();
function letsJQuery() {
$.each(userids, function() {
$(".post-signature:contains('"+this+"')").remove();
$("div.answer").each(function() {
var paCount = $(this).find(".post-signature").length;
if (paCount == 0) { $(this).remove(); }
if (paCount == 1 && ($(this).find(".post-signature:contains('community wiki')").length == 1)) { $(this).remove(); }
});
$("a.comment-user:contains('"+this+"')").closest("tr.comment").remove();
$("a[rel='canonical']:contains('"+this+"')").html("unknown (Google)");
var randHash = "";
for(var i = 0; i < 4; i++) { randHash += Math.floor(Math.random()*0x100000000).toString(16); }
$(".user-gravatar32>a[href*='"+this.replace(/\s/g,"-").toLowerCase()+"']>img")
.attr("src", "http://www.gravatar.com/avatar/"+randHash+"?s=32&d=identicon&r=PG");
});
}
$(window).ajaxComplete(function() {
letsJQuery();
});
})();
paCount
definition:.filter(function(){ return $(this) .find("a[href*=revisions]:contains(edited)") .length == 0; })
- it's needed to hide answers that a killfiled user posted and edited.