Tag Preview

Show tags on hover.

Tính đến 27-03-2019. Xem phiên bản mới nhất.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Tag Preview
// @version      1.32
// @description  Show tags on hover.
// @author       Hauffen
// @include      /https?:\/\/(e-|ex)hentai\.org\/.*/
// @require      https://code.jquery.com/jquery-3.3.1.min.js
// @namespace    https://greasyfork.org/users/285675
// ==/UserScript==

(function() {
    var $tagP = $('<div id="tagPreview">');
    $tagP.css({
        position:'absolute',
        zIndex: '2',
        visiblility:'hidden',
        maxWidth: '400px',
        background: $('.ido').css("background"),
        border:'1px solid #000',
        padding: '10px'
    });
    $tagP.appendTo("body");

    var element;
    if(document.getElementsByTagName("select").length === 0) {
        return;
    }

    switch(document.getElementsByTagName("select")[0].selectedIndex){
        case 0:
            element = ".gl3m a";
            break;
        case 1: // delete this case if you don't want it on compact view.
            element = ".gl3c a";
            break;
        default:
            element = ".gl3t a";
            break;
    }

    $('.itg').on('mouseover', `${element}`, function(e) {
        if(document.getElementById('tagPreview').children.length > 2) {
            document.getElementById('tagPreview').innerHTML = "Loading...";
            $tagP.empty();
        }
        var $content = $('<div>');
        $content.load(this.href, function() {
            document.getElementById('tagPreview').innerHTML = $('#gd2', this).html() + $('#taglist', this).html();

            var posY, posX = (e.pageX + 432 < screen.width) ? e.pageX + 10 : e.pageX - 412;
            var scrollHeight = $(document).height();
            var scrollPosition = $(window).height() + $(window).scrollTop();

            if ((scrollHeight - scrollPosition) < (scrollHeight / 10)) {
                posY = (e.pageY + 300 < scrollHeight) ? e.pageY + 10 : e.pageY - 300;
            } else {
                posY = e.pageY + 10;
            }

            $tagP.css({
                left: posX,
                top: posY,
                border: '1px solid ' + window.getComputedStyle(document.getElementsByTagName("a")[0]).getPropertyValue("color"),
                visibility: 'visible'
            });
        });
    }).on('mousemove', `${element}`,function(e) {
        var posY, posX = (e.pageX + 432 < screen.width) ? e.pageX + 10 : e.pageX - 412;
        var scrollHeight = $(document).height();
        var scrollPosition = $(window).height() + $(window).scrollTop();

        if ((scrollHeight - scrollPosition) < (scrollHeight / 10)) {
            posY = (e.pageY + document.getElementById('tagPreview').offsetHeight < window.innerHeight) ? e.pageY + 10 : e.pageY - 10 - document.getElementById('tagPreview').offsetHeight;
        } else {
            posY = e.pageY + 10;
        }

        $tagP.css({
            visibility:'visible',
            top: posY,
            left: posX
        });
    }).on('mouseout', `${element}`, function() {
        $tagP.css({
            visibility:'hidden'
        });
        document.getElementById('tagPreview').innerHTML = "Loading...";
        $tagP.empty();
    });

    $(document).on('scroll', function() {
        document.getElementById('tagPreview').style.visibility = 'hidden';
    });
})();