Last active
May 29, 2016 19:05
-
-
Save vshivam/94d18c5d652217a449a5b785cbda1073 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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