Ex-Hentai: Frame Popups

Embed popup window instead of another window.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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