Remove Ads on Tetris Friends

This script removes ads on www.tetrisfriends.com.

Verze ze dne 02. 06. 2017. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name           Remove Ads on Tetris Friends
// @description    This script removes ads on www.tetrisfriends.com.
// @namespace      http://userscripts.org/users/173064
// @include        http://www.tetrisfriends.com/*
// @license        GNU General Public License v3.0
// @version        1.0.170602.0412
// @grant          none
// @noframes
// ==/UserScript==

try {
(function () {
    function selectNode(xpathExpression) {
        return document.evaluate(xpathExpression, document, null,
                XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
    }

    function removeElementById(elementId) {
        var
            element;
        element = document.getElementById(elementId);
        if (element && element.parentNode) {
            element.parentNode.removeChild(element);
        }
    }

    function removeElementByClass(elementClass) {
        var
            element;
        element = selectNode("//div[@class='" + elementClass + "']");
        if (element && element.parentNode) {
            element.parentNode.removeChild(element);
        }
    }

    function hideElementByClass(elementClass) {
        var
            element;
        element = selectNode("//div[@class='" + elementClass + "']");
        if (element) {
            element.style.visibility = "hidden";
        }
    }

    function main() {
        var
            elementIds = [
                "rail_left",
                "rail_left_incentive",
                "rail_right",
                "rail_right_incentive",
                "sponsored_options",
                "_adr_abp_iframe_1"
            ],
            elementClasses = [
                "friends_ad_container",
                "gallery_ad_container",
                "game_ad_container",
                "gamesPage_ad_container",
                "home_ad_container",
                "home_ad_left_rail",
                "home_ad_right_rail",
                "home_custom_ad_container",
                "messages_ad_container",
                "mission_ad_container",
                "news_ad_container",
                "profile_ad_container",
                "tetris_house_ad_container",
                "tetris_house_ad_container margintop_5px",
                "tips_ad_space"
            ],
            elementClassesHide = [
                "leaderboard_ad_container"
            ],
            i,
            node;
        for (i = 0; i < elementIds.length; i += 1) {
            removeElementById(elementIds[i]);
        }
        for (i = 0; i < elementClasses.length; i += 1) {
            removeElementByClass(elementClasses[i]);
        }
        for (i = 0; i < elementClassesHide.length; i += 1) {
            hideElementByClass(elementClassesHide[i]);
        }
        if (document.location.href.indexOf("/game.php") > -1) {
            setTimeout("gamePrerollComplete();", 1000);
        }
    }

    return function () {
        main();
    };
}())();
} catch (e) {
    alert("Error in 'Remove Ads on Tetris Friends':\n" +
            e.toString() + "\n" + e.stack);
}