Skip to content

Instantly share code, notes, and snippets.

@vshivam vshivam/spoiler-killer.js
Last active May 29, 2016

Embed
What would you like to do?
// ==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
You can’t perform that action at this time.