Using Greasemonkey / userscript to remove unwanted web content

Allmost every Norwegian newspaper website have this stupid, meaningless comment section below their articles, where 98% of the posts are just crap.

I tend to spend time reading this crap, but not any more, because I’ve created a Greasemonkey userscript for Chrome, which simply hides this noise.

Creating such a script was very easy, and Greasemonkey is really powerfull!

The script is downloadable from http://kvisberg.net/scripts/RUCNorwegianNews/ and comes with absolutely no guarantee.

// ==UserScript==
// @author olekvi@kvisberg.net
// @version 1.21
// @name RUCNorwegianNews
// @description Removesuser comments on Norwegian news websites
// @match http://www.adressa.no/*
// @match http://www.aftenposten.no/*
// @match http://oslopuls.aftenposten.no/*
// @match http://www.dagbladet.no/*
// @match http://e24.no/*
// @match http://www.nrk.no/*
// @match http://nrk.no/*
// @match http://www.nrk.no/*
// @match http://www.vg.no/*
/* StartHistory
 
v.1.21 - 2011-02-27
Supporting nrk.no and e24.no
 
v 1.2 - 2011-02-23
Supporting adressa.no
 
v 1.1 - 2011-02-22
Supporting oslopuls.aftenposten.no
Total rewrite, not longer only a ugly hack
 
v 1.0 - 2011-02-22
Supporting aftenposten.no, dagbladet.no and vg.no
 
EndHistory */
// ==/UserScript==
 
/* this is not a hash, but it will do the trick here! */
var comments = [];
comments['www.adressa.no'] = 'debate';
comments['www.aftenposten.no'] = 'articleComment';
comments['oslopuls.aftenposten.no'] = 'userCommentsListing';
comments['www.dagbladet.no'] = 'kommentarer';
comments['e24.no'] = 'disqus_thread';
comments['www.e24.no'] = 'disqus_thread';
comments['nrk.no'] = 'articlecomments';
comments['www.nrk.no'] = 'articlecomments';
comments['www.vg.no'] = 'disqus_thread';
 
for (host in comments) {
  if (host == window.location.host) {
    removeComments(comments[host]);
  }
}
 
function removeComments(id) {
  var commentId = document.getElementById(id);
  if (commentId) {
    commentId.parentNode.removeChild(commentId);
  }
}

More or less related posts:

This entry was posted in Code, Misc and tagged , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *