Clutter Disappearifier

hides ads and navigation from around the comics

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name        Clutter Disappearifier
// @namespace   abrad45
// @description hides ads and navigation from around the comics
// @include     http://www.mspaintadventures.com/*
// @include     http://mspaintadventures.com/*
// @require     https://code.jquery.com/jquery-2.2.3.min.js
// @require     https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.1.1/js.cookie.js
// @version     2
// @grant       none
// ==/UserScript==

$(function () {
    if(/s=6/.test(window.location.search)) {
        var $body = $('body');
        var cookieName = 'homestuck_cd';
        var appear = 'Appearify Clutter';
        var disappear = 'Disappearify Clutter';

        if (getCookieValue() !== 0) {
            $body
                .css('background-color', '#c6c6c6')
                .find('> center > table > tbody > tr:not(:eq(1))')
                    .hide();

            setCookie(1, {
                'path': '/',
                'expires': 180
            });
        }

        $('table[width=600]')
            .first()
            .parent()
                .css('position', 'relative')
                .append(
                    $('<div />',
                        {
                            'id': 'clutter_disappearifier',
                            'css': {
                                'position': 'absolute',
                                'right': '5px',
                                'top': '0'
                            }
                        }
                    ).append(
                        $('<a />',
                            {
                                'href': '#',
                                'text': function () {
                                    if(getCookieValue() === 1) {
                                        return appear;
                                    } else {
                                        return disappear;
                                    }
                                }
                            }
                        )
                    )
                );

        $('#clutter_disappearifier a').click(function () {
            if ($('body[style]').length) {
                $body
                    .removeAttr('style')
                    .find('> center > table > tbody > tr')
                        .show();

                setCookie(0);
                $(this).text(disappear);
            } else {
                $body
                    .css('background-color', '#c6c6c6')
                    .find('> center > table > tbody > tr:not(:eq(1))')
                        .hide();

                setCookie(1);
                $(this).text(appear);
            }
            return false;
        });
    }

    function getCookieValue() {
        return Number(Cookies.get(cookieName)) || -1;
    }

    function setCookie(val, options) {
        if (typeof options === "object") {
            Cookies.set(cookieName, !!val, options);
        } else {
            Cookies.set(cookieName, !!val);
        }
    }
});