Sleazy Fork is available in English.

E-Hentai & ExHentai Fade or hide viewed galleries and tag hider

Fade or hide viewed galleries and hide flagged tags on e-hentai and exhentai

2017/12/17時点のページです。最新版はこちら。

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください。
// ==UserScript==
// @name        E-Hentai & ExHentai Fade or hide viewed galleries and tag hider
// @namespace   https://greasyfork.org/users/25356
// @description Fade or hide viewed galleries and hide flagged tags on e-hentai and exhentai
// @version     3

// @include     https://exhentai.org/*
// @include     https://e-hentai.org/*

// @grant		GM_getValue
// @grant		GM_setValue

// @run-at 		document-start

// @require		https://code.jquery.com/jquery-git.min.js
// @author      CoLdAsIcE
// ==/UserScript==

(function () {
    
    var $hideGal = GM_getValue("EHXFade_hidevisited", false);
    var $viewedCounter = 0;

    function isGalVisited(gid) {

        var $md = GM_getValue("g_" + gid, 0);
        if ($md == 1) {
            return true;
        }
        return false;
    }

    function visitGal(gid) {

        if (!isGalVisited(gid)) {
            GM_setValue("g_" + gid, 1);
        }
    }

    function saveViewedGal() {

        if (document.URL.match(/^https:\/\/(e-|e[^-])hentai\.org\/g\/.*$/)) { //gallery case
            //record visited galleries to local DB
            var $gal_idx = document.URL.match(/^https:\/\/(?:e-|e[^-])hentai\.org\/g\/(\d*)\/.*$/);

            if (!isNaN($gal_idx[1])) {

                var gal_id = parseInt($gal_idx[1], 10);
                visitGal(gal_id);
            }
        }
    }

    function fadeThumb($tag) {

        var $p = $tag.closest('.id1'); //also fade title in gallery

        var $alpha = parseFloat(0.2);
        if (isNaN($alpha))
            $alpha = '0.2';

        $p.css('opacity', $alpha);

        $p.hover(
            function () {
                $(this).stop().fadeTo('fast', 1);
            },
            function () {
                $(this).stop().fadeTo('fast', $alpha);
            }
        );
    }

    function fadeViewedGal() {
        $('.itg > div.id1').each(function (ix) {
            $(this).find(".id44").each(function (index) {
                if (document.URL.match(/^https:\/\/(e-|e[^-])hentai\.org\/(?!s).*$/) && self == top) { //search / index case, exclude iframe
                    var $tagContainer = $(this);
                    var $gallery = $(this).closest('.id1');

                    var $gal_href = $tagContainer.closest('.id1').find('div.id2 a').first().attr('href');

                    var $gal_idx = $gal_href.match(/^https:\/\/(?:e-|e[^-])hentai\.org\/g\/(\d*)\/.*$/);

                    if (!isNaN($gal_idx[1])) {
                        var gal_id = parseInt($gal_idx[1], 10);
                        $tagContainer.closest('.id1').find('.id2').addClass('vx');
                        if (isGalVisited(gal_id)) {
                            $viewedCounter++

                            if ($hideGal == false) {
                                fadeThumb($tagContainer);
                                $gallery.show();
                            } else {
                                $gallery.hide();
                            }
                        }
                    }
                }
            });
        });
    }

    function removeBadTags() {
        $('.itg > div.id1').each(function (ix) {

            var $blankGif = $(this).find(".id3 img").attr('src');
            var $image = $(this);
            if ($blankGif == "https://exhentai.org/img/blank.gif") {
                $image.hide();
            }
        });
    }

    function css() {
        $('<style type="text/css">' +
            'div.hideGal {width:65px; height:auto; position:fixed; margin-left:-76px; background-color:#4F535B; color:skyblue;border: 1px solid #000000; z-index: 10; cursor:pointer; }' +
            'div.hideGal div.tab { margin:6px; }' +
            'div.id2 a:visited, div.id2 a:visited span, .vx a:visited, .vx a:visited span  {font-weight:normal; color:#4b90eb !important; }' +
            '</style>').appendTo("head");
    }

    function hideVisitedGal() {
        
        //add a hide gallery tab
        if (!$hideGal) {
            $('div.ido').prepend('<div class="hideGal"><div class="tab" id="toggleseen"><center><span id="hideShow">Hide</span> - <span id="viewed">0</span></center></div></div>');
        } else {
            $('div.ido').prepend('<div class="hideGal"><div class="tab" id="toggleseen"><center><span id="hideShow">Show</span> - <span id="viewed">0</span></center></div></div>');
        }

        //hide or show gallery
        $('#toggleseen').parent().click(function (e) {

            $hideGal = !$hideGal;

            GM_setValue("EHXFade_hidevisited", $hideGal);

            if ($hideGal) {
                $("#hideShow").text("Show");
            } else {
                $("#hideShow").text("Hide");
            }

            applyChanges();

        });
    }

    function applyChanges() {
        fadeViewedGal();
    }

    function runEHXFade() {
        css();
        hideVisitedGal();

        saveViewedGal();
        fadeViewedGal();
        removeBadTags();


        $("#viewed").text($viewedCounter);
    }

    addEventListener('DOMContentLoaded', runEHXFade, false);
})();