Tumblr Savior

By Bjorn Stromberg Last update Feb 6, 2009 — Installed 381 times. Daily Installs: 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 2, 0, 0, 0, 1, 0, 19, 2, 1, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 1, 0, 0

There are 5 previous versions of this script.

// ==UserScript==
// @name           Tumblr Savior
// @namespace      bjornstar
// @description    Saves you from ever having to see another post about certain things ever again
// @include        http://www.tumblr.com/dashboard
// @include        http://www.tumblr.com/dashboard/*
// @include        http://www.tumblr.com/show/*
// ==/UserScript==

function needstobesaved(theStr){
  var blackList = new Array('jakob','lodwick','obama','mccain','iphone','baseball', 'julia allison', 'palin', 'apartment therapy', 'pixdaus', 'super bowl', 'superbowl', 'nfl', 'kari-shma');
  var whiteList = new Array('bjorn', 'betina');
  var blacklisted = false;
  var whitelisted = false;
  
  for(var i=0;i<=whiteList.length;i++) {
    if(theStr.toLowerCase().indexOf(whiteList[i])>=0) {
      whitelisted = true;
    }
  }

  if (!whitelisted) {
    for(var i=0;i<=blackList.length;i++) {
      if(theStr.toLowerCase().indexOf(blackList[i])>=0) {
        blacklisted = true;
      }
    }
  }
  return blacklisted;
}

var liPosts = document.getElementsByTagName('li');
  
for (var i=0;i<=liPosts.length;i++) {
  if (liPosts[i].id.substring(0,4)=='post' && liPosts[i].className.indexOf('not_mine') >= 0) {
    var savedfrom = needstobesaved(liPosts[i].innerHTML);
    if (savedfrom) {
      var div_filtered = document.createElement('div');
      div_filtered.style.display = 'none';

      while (liPosts[i].childNodes.length > 1) {
        div_filtered.appendChild(liPosts[i].childNodes[0]);
      }

      var div_notice = document.createElement('div');
      div_notice.className = 'post_info';
      div_notice.innerHTML = 'You have been saved from this post, it had something you didn\'t want to see in it. <a onclick="this.parentNode.style.display=\'none\'; this.parentNode.nextSibling.style.display=\'\'; return false;" href="#"><i>Click here</i></a> if you cannot resist the temptation.';

      liPosts[i].appendChild(div_notice);
      liPosts[i].appendChild(div_filtered);
    }
  }
}