Sunday, 29 May 2016

Greasemonkey script to block Game of Thrones spoilers


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://**
// @include        https://**
// @require
// @require
// @grant          none
// @version 1
// @namespace
// @description Blacken facebook posts possibly containing Game of Thrones spoilers.
// copied from
// ==/UserScript==

    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(){
                    $(node).on("mouseleave", function(){
                })(overlay, node);
    waitForKeyElements("div.userContentWrapper", actionFunction);

NOTE : This script is copied over from  It's original version can be found at (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 -

Related Links

No comments:

Post a Comment

t> UA-39527780-1 back to top