return false;
}
var capturingelement = null; // the element who registered to the event
var srcelement = null; // the clicked on element
var closestparentlink = null;
if (window.event != null) {
capturingelement = window.event.currenttarget;
srcelement = window.event.srcelement;
}
if (srcelement != null && srcelement instanceof htmlelement) {
closestparentlink = srcelement.closest('a');
if (closestparentlink && closestparentlink.href) {
openwndarguments[3] = closestparentlink.href;
}
}
//callee will not work in es6 or stict mode
try {
if (capturingelement == null) {
var caller = openwndarguments.callee;
while (caller.arguments != null && caller.arguments.callee.caller != null) {
caller = caller.arguments.callee.caller;
}
if (caller.arguments != null && caller.arguments.length > 0 && caller.arguments[0].currenttarget != null) {
capturingelement = caller.arguments[0].currenttarget;
}
}
} catch (e) {}
/////////////////////////////////////////////////////////////////////////////////
// blocked if a click on background element occurred ( or document)
/////////////////////////////////////////////////////////////////////////////////
if (capturingelement == null) {
window.pbreason = 'blocked a new window opened without any user interaction';
useoriginalopenwnd = false;
} else if (capturingelement != null && (capturingelement instanceof window || isparentwindow(capturingelement) || capturingelement === document || capturingelement.url != null && capturingelement.body != null || capturingelement.nodename != null && (capturingelement.nodename.tolowercase() == "body" || capturingelement.nodename.tolowercase() == "document"))) {
window.pbreason = 'blocked a new window opened with url: ' openwndarguments[0] ' because it was triggered by the ' capturingelement.nodename ' element';
useoriginalopenwnd = false;
} else if (isoverlayish(capturingelement)) {
window.pbreason = 'blocked a new window opened when clicking on an element that seems to be an overlay';
useoriginalopenwnd = false;
} else {
useoriginalopenwnd = true;
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
// block if a full screen was just initiated while opening this url.
/////////////////////////////////////////////////////////////////////////////////
var fullscreenelement = document.webkitfullscreenelement || document.mozfullscreenelement || document.fullscreenelement;
if (new date().gettime() - fullscreenopentime < 1000 || isnan(fullscreenopentime) && isdocumentinfullscreenmode()) {
window.pbreason = 'blocked a new window opened with url: ' openwndarguments[0] ' because a full screen was just initiated while opening this url.';
/* jra removed
if (window[script_params.fullscreenfnkey]) {
window.cleartimeout(window[script_params.fullscreenfnkey]);
}
*/
if (document.exitfullscreen) {
document.exitfullscreen();
} else if (document.mozcancelfullscreen) {
document.mozcancelfullscreen();
} else if (document.webkitcancelfullscreen) {
document.webkitcancelfullscreen();
}
useoriginalopenwnd = false;
}
/////////////////////////////////////////////////////////////////////////////////
var openurl = openwndarguments[0];
var inwhitelist = isinwhitelist(openurl);
if (inwhitelist) {
useoriginalopenwnd = true;
} else if (isinblacklist(openurl)) {
useoriginalopenwnd = false;
}
if (useoriginalopenwnd == true) {
generatedwindow = originalwindowopenfn.apply(this, openwndarguments);
// save the window by name, for latter use.
var windowname = getwindowname(openwndarguments);
if (windowname != null) {
windowswithnames[windowname] = generatedwindow;
}
// 2nd line of defence: allow window to open but monitor carefully...
/////////////////////////////////////////////////////////////////////////////////
// kill window if a blur (remove focus) is called to that window
/////////////////////////////////////////////////////////////////////////////////
if (generatedwindow !== window) {
var opentime = new date().gettime();
var originalwndblurfn = generatedwindow.blur;
generatedwindow.blur = function () {
if (new date().gettime() - opentime < 1000 && !inwhitelist /* one second */) {
window.pbreason = 'blocked a new window opened with url: ' openwndargu