Skip to content

Instantly share code, notes, and snippets.

@kensnyder
Created February 10, 2011 21:00
Show Gist options
  • Save kensnyder/821334 to your computer and use it in GitHub Desktop.
Save kensnyder/821334 to your computer and use it in GitHub Desktop.
Hide spammy posts on google groups
var blacklist = {
title: [
/\bsexy?\b/i,
/online order/i,
/buy \w+ online/i,
/hot videos/i,
/earn money/i,
/prescription/i
],
body: [
/free shipping/i,
/\bsexy?\b/i,
/!!!/i,
/hot videos/i,
/\[link\]<\/a> ?<a[^>]+>\[link\]/,
/cheapest/i
]
};
function matchesAny(text, regexes) {
var regex, i = 0;
while ((regex = regexes[i++])) {
if (regex.test(text)) {
return true;
}
}
return false;
}
var posts = document.querySelectorAll('.maincontoutboxatt table');
var post, i = 0, title, body, fontTags;
while ((post = posts[i++])) {
fontTags = post.querySelectorAll('font');
title = fontTags[0];
if (!title) {
continue;
}
body = fontTags[1];
if (!body) {
continue;
}
if (
matchesAny(title.innerHTML, blacklist.title)
|| matchesAny(body.innerHTML, blacklist.body)
) {
post.style.display = 'none'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment