Created
February 10, 2011 21:00
-
-
Save kensnyder/821334 to your computer and use it in GitHub Desktop.
Hide spammy posts on google groups
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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