Clutter Disappearifier

hides ads and navigation from around the comics

Versione datata 17/04/2016. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==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);
        }
    }
});