Skip to content

Instantly share code, notes, and snippets.

@vshivam
Last active May 25, 2016 12:14
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 vshivam/9080a0b5ece35689163ed12955c131a9 to your computer and use it in GitHub Desktop.
Save vshivam/9080a0b5ece35689163ed12955c131a9 to your computer and use it in GitHub Desktop.
Greasemonkey script to hide/mark spoilers on your Facebook homepage.
// ==UserScript==
// @name Spoiler Killer
// @include http://*.facebook.com/*
// @include https://*.facebook.com/*
// @require http://code.jquery.com/jquery-1.7.1.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant none
// @version 1
// @namespace http://shivamverma.info
// @description Blacken/Completely hide facebook status updates with Game of Thrones spoilers
// ==/UserScript==
(function(){
/*** NOW DEPRECATED IN FAVOUR OF
* https://gist.github.com/vshivam/94d18c5d652217a449a5b785cbda1073
***/
var spoiler = 'I am a dumbass ! (<i>via Spoiler Killer</i>)';
var terms = ['spoiler', 'game of thrones', 'hodor', 'jon snow', 'khaleesi', 'stark', 'dothraki'];
var hide = false;
function actionFunction(node){
var content = node.html();
content = content.toLowerCase();
$.each(terms, function(index, term){
if(content.indexOf(term) > -1){
console.log(node);
if(hide){
node.html(spoiler);
} else {
node.css('background', 'black');
$(node).on("mouseenter", function(){
$(this).css('background', 'white');
});
$(node).on("mouseleave", function(){
$(this).css('background', 'black');
});
}
}
});
}
waitForKeyElements("div.userContent", actionFunction);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment