I’m Tired of the ALS Ice Bucket Challenge Videos

Okay, I know the ALS Ice Bucket Challenge is for a noble cause and to spread awareness about amyotrophic lateral sclerosis but I’m tired of seeing each and everyone taking up this challenge and posting it on their Facebook. My News Feed is full of videos where people I am connected to are dumping a bucket full of ice water on their heads. Okay, here’s how I’ll not be seeing any more ice bucket  content on my Facebook News Feed – a chrome extension to block it (thanks to this Reddit thread for the idea).

ice-bucket-challenge

Download the Extension and drop it into chrome://extensions – I don’t wish to put it up on Chrome Web Store because I don’t think it would so much valuable to anyone as it is to me.

Code Explanation

Since this is my first extension, it does nothing much apart from blocking the all News Feed stories that contain the words “Ice Bucket Challenge”. If you wish to build a Chrome Extension, Google is your best friend.

A simple manifest.json

{
 "manifest_version": 2,
"name": "ALS Ice Bucket Challenge Block",
 "description": "Blocks ALS Ice Bucket Challenge content.",
 "version": "1.0",
 "browser_action": {
 "default_icon": "icon.png",
 "default_popup": "popup.html"
 },
 "content_scripts": [
 {
 "matches": ["https://www.facebook.com/*"],
 "js": ["jquery.js","alsblock.js"]
 }
 ]
}

The alsblock.js code does only this:

  1. Find all news feed items with the words “Ice Bucket Challenge”
  2. Remove them (assuming all those items relate to ALS Ice Bucket and not anything else).

Here’s the code:

$(document).ready(function(){
var item = document.getElementsByClassName("mbm");
var searchText = "ice bucket challenge";
var blocked = 0;
for (var i = 0; i < item.length; i++) {
 var content = item[i].textContent;
 if (content.indexOf(searchText) > -1) {
 console.log(content);
 child = item[i];
 child.parentNode.removeChild(child);
 blocked++;
 console.log(blocked + " Ice Block texts found");
 }
}
});

Leave a Reply