Skip to content

Instantly share code, notes, and snippets.

@vshivam
Last active May 29, 2016 19:05
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/94d18c5d652217a449a5b785cbda1073 to your computer and use it in GitHub Desktop.
Save vshivam/94d18c5d652217a449a5b785cbda1073 to your computer and use it in GitHub Desktop.
// ==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 facebook posts possibly containing Game of Thrones spoilers.
// ==/UserScript==
(function(){
var spoiler = 'I am a dumbass ! (<i>via Spoiler Killer</i>)';
var terms = ['spoiler', 'game of thrones', 'hodor', 'jon snow', 'khaleesi', 'stark', 'dothraki'];
function actionFunction(node){
var content = node.html();
content = content.toLowerCase();
$.each(terms, function(index, term){
if(content.indexOf(term) > -1){
var overlay = $('<div />' ).css({
position: "absolute",
width: "100%",
height: "100%",
left: 0,
top: 0,
zIndex: 1000000,
background: "#000000",
});
(function(overlay, node){
overlay.appendTo(node.css("position", "relative"));
$(node).on("mouseenter", function(){
overlay.hide();
});
$(node).on("mouseleave", function(){
overlay.show();
});
})(overlay, node);
}
});
}
waitForKeyElements("div.userContentWrapper", actionFunction);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment