Background
Greasemonkey is a Firefox plugin that runs user scripts just like tampermonkey in chrome. In this post we will see a simple script that will blacklist certain words appearing in Game of thrones which will potentially be spoilers.
Greasemonkey script to block Game of Thrones spoilers
Script is as follows -
// ==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); })();
NOTE : This script is copied over from https://gist.github.com/vshivam/94d18c5d652217a449a5b785cbda1073. It's original version can be found at https://gist.github.com/vshivam/9080a0b5ece35689163ed12955c131a9 (simply replaces text)
Script essentially blackens the posts that contain spoiler words. Feel free to add/remove words as you choose suitable. Make sure that the script is running on the site you intend it to be. You can test that from Greasemonkey icon near URL bar. See following screenshot for details -
Script essentially blackens the posts that contain spoiler words. Feel free to add/remove words as you choose suitable. Make sure that the script is running on the site you intend it to be. You can test that from Greasemonkey icon near URL bar. See following screenshot for details -