Skip to content

Instantly share code, notes, and snippets.

@robbyrussell
Created October 2, 2008 03:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robbyrussell/14264 to your computer and use it in GitHub Desktop.
Save robbyrussell/14264 to your computer and use it in GitHub Desktop.
greasemonkey script to protect you from palin videos on youtube
// ==UserScript==
// @name SaveYourselfFromPalin
// @namespace http://www.youtube.com/
// @description saves you from the emotion that you feel after seeing another sarah palin clip
// @include http://www.youtube.com/*
// ==/UserScript==
var sarah = /(palin)/;
function pitbull_exists(lipstick) {
for (var tx = document.evaluate('//text()[normalize-space(.)!=""]', document, null, 6, null), t, i = 0; t = tx.snapshotItem(i); i++) {
var before = t.textContent, st, matched = false;
if (t.parentNode.tagName == 'STYLE' || t.parentNode.tagName == 'SCRIPT') continue;
while ((st = before.search( lipstick )) != -1) { return true; }
} return false;
}
if (pitbull_exists(sarah)) {
alert('WARNING!!!!!\nThis contents of this youtube video might include Sarah Palin. You might want to go punch yourself in the face instead of watching it....');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment