Ex-Hentai: Frame Popups

Embed popup window instead of another window.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Ex-Hentai: Frame Popups
// @namespace    Org.Jixun
// @version      0.2
// @description  Embed popup window instead of another window.
// @author       Jixun
// @include      http://exhentai.org/g/*
// @include      http://g.e-hentai.org/g/*
// @grant        none
// ==/UserScript==

////////////////////////////////////////////////
///                                 样式表   ///
////////////////////////////////////////////////
var style = document.createElement('style');
style.textContent = (function(){/*
#lb-oberlay {
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    position: fixed;
    z-index: 100000;
    overflow: hidden;
    background: rgba(35,35,35,.7);
}

#lb-frame {
    box-shadow: 5px 5px 10px black;
    position: fixed;
    left: 50%;
    top: 50%;
    z-index: 100001;
    border: 0;
}
*/}).toString().slice(15,-4);
document.head.appendChild(style);

////////////////////////////////////////////////
///                           重叠元素就绪   ///
////////////////////////////////////////////////
var oberlay = document.createElement('div');
oberlay.id='lb-oberlay';
oberlay.style.display = 'none';

var popup = document.createElement('iframe');
popup.id  = 'lb-frame';
popup.style.display = 'none';
popup.setAttribute('seamless', true);

document.body.appendChild(oberlay);
document.body.appendChild(popup);

////////////////////////////////////////////////
///                           绑定元素事件   ///
////////////////////////////////////////////////
function hideOberlay () {
    oberlay.style.display = popup.style.display = 'none';
}
oberlay.onclick = hideOberlay;
popup.onload = function () {
    var wnd = popup.contentWindow;
    wnd.close = hideOberlay;
    
    [].map.call(wnd.document.querySelectorAll('[style*="height"]'), function (x) {
        x.style.height = '';
    });
};

////////////////////////////////////////////////
///                            仿 LightBox   ///
////////////////////////////////////////////////
window.popUp = function (url, w, h) {
    // 强行重写 /w\
    w += 20;
    h += 20;
    
    if (popup.src != url)
        popup.src = url;
    
    popup.style.width  = w + 'px';
    popup.style.height = h + 'px';
    popup.style.marginLeft = -w/2 + 'px';
    popup.style.marginTop  = -h/2 + 'px';
    oberlay.style.display = popup.style.display = 'block';
};