Last active
June 12, 2016 05:25
-
-
Save aniket91/bb60c2c11ed904d1ac997238af32deec to your computer and use it in GitHub Desktop.
Greasemonkey script to blackout Game of thrones spoiler posts on facebook
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://opensourceforgeeks.blogspot.in/ | |
// @description Blacken facebook posts possibly containing Game of Thrones spoilers. | |
// copied from https://gist.github.com/vshivam/94d18c5d652217a449a5b785cbda1073 | |
// ==/UserScript== | |
(function(){ | |
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