Suppressing User Comments on AnnArbor.com
I consider AnnArbor.com my primary source of local news, but find its user comments to be uninformative and distracting. So, I assembled a method to hide all traces of user comments while browsing their site. This requires Firefox and a Greasemonkey script. This is by no means perfect, but it works. Take it as you will and read in peace!
The script:
// ==UserScript==
// @name hide annarbor.com comments
// @namespace aadotcomcblock
// @include http://www.annarbor.com/*
// ==/UserScript==
var all_li, specific_li;
all_li = document.evaluate(
“//li[@class=’comments’]”,
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
for (var i = 0; i < all_li.snapshotLength; i++) {
specific_li = all_li.snapshotItem(i);
specific_li.parentNode.removeChild(specific_li);
}
var all_p, this_p;
all_p = document.evaluate(
“//p[@class=’post_comment_now’]”,
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
for (var i = 0; i < all_p.snapshotLength; i++) {
this_p = all_p.snapshotItem(i);
this_p.parentNode.removeChild(this_p);
}
var all_div, one_div;
all_div = document.evaluate(
“//div[@class=’news_comments clearfix’]”,
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
for (var i = 0; i < all_div.snapshotLength; i++) {
one_div = all_div.snapshotItem(i);
one_div.parentNode.removeChild(one_div);
}
var all_urlcomments, single_urlcomments;
all_urlcomments = document.evaluate(
“//a[@class=’comments’]”,
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
for (var i = 0; i < all_urlcomments.snapshotLength; i++) {
single_urlcomments = all_urlcomments.snapshotItem(i);
single_urlcomments.parentNode.removeChild(single_urlcomments);
}
var removeComments = document.getElementById(‘comments’);
if (removeComments) {
removeComments.parentNode.removeChild(removeComments);
}
Thanks to E. Clarke for help on this.