Ex-Hentai: Frame Popups

Embed popup window instead of another window.

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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 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.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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         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';
};