3月5日,全市人大立法工作务虚会在钦州召开。梁晶晶 摄
与会人员认真了解2018年地方立法工作,并对2019年立法工作提出意见建议。梁晶晶 摄
本网讯 为深入贯彻科学立法、民主立法、依法立法的要求,凝聚智慧与共识,提高人大立法质量,3月5日,市人大常委会召开全市人大立法工作务虚会。
会议立足于2019年立法工作计划,对茅尾海、钦州港七十二泾、三墩以及三娘湾等海域的海洋生态环境保护、航道规划、入海江河污染治理等情况开展立法调研,并以问题为导向,深入探讨我市海域立法空间,进一步总结我市人大立法工作的经验和不足,更新立法理念,创新制度设计,主动谋划新形势下地方立法工作。
与会同志就如何调动县区人大参与立法的积极性、加强启发和互动式调研形式、充分发挥政府部门以及人大代表作用、有效提高地方性法规公众认知度、理顺和完善立法工作制度机制等内容对今年的立法工作提出了具体建议。
会议指出,通过集思广益,对2019年的人大立法的制定、实施、宣传工作思路更加明晰,就坚持和贯彻落实好市委意图,进一步完善各项立法计划并科学安排落实提出几点意见:一是要求人大立法队伍切实提高政治站位,夯实理论功底和立法技能,增强地方立法工作的责任感和紧迫感;二是要把准方向,有序落实好五年立法规划,着力抓好重点领域立法;三是要健全机制,强化协调,发挥好县区人大的作用,增强地方立法工作合力。(梁晶晶)
(function () {
var pb_blacklist = [];
var pb_whitelist = ["pan.baidu.com","youpin.mi.com","lwwf1.chatango.com","study.163.com","qq.com","tmall.com","iqiyi.com","jd.com","jiyoujia.com","engage.wixapps.net","li<x>nkedin.com","google","www.gmail.com","www.pinterest.com","www.youtube.com","www.facebook.com","search.yahoo.com","chrome://newtab","www.food.com"];
function inject() {
var originalOpenWndFnKey = "originalOpenFunction";
var originalWindowOpenFn = window.open;
var originalCreateElementFn = document.createElement;
var originalAppendChildFn = HTMLElement.prototype.appendChild;
var originalCreateEventFn = document.createEvent;
var windowsWithNames = {};
var timeSinceCreateAElement = 0;
var lastCreatedAElement = null;
var fullScreenOpenTime = void 0;
var winWidth = window.innerWidth;
var winHeight = window.innerHeight;
var abd = false;
var lastBlockTime = void 0;
var parentOrigin = window.location != window.parent.location ? document.referrer || window.parent.location || '*' : document.location;
var parentRef = window.parent;
//window[originalOpenWndFnKey] = window.open; // save the original open window as global param
function getAbsoluteURL(ba<x>seURL) {
if (/^about:blank/i.test(ba<x>seURL)) {
return ba<x>seURL;
}
if (/^(https?:)?\/\//.test(ba<x>seURL)) {
return ba<x>seURL;
}
ba<x>seURL = location.origin + (!/^\//.test(ba<x>seURL) ? '/' : '') + ba<x>seURL;
return ba<x>seURL;
}
function newWindowOpenFn() {
var openWndArguments = arguments;
var useOriginalOpenWnd = true;
var generatedWindow = null;
function getWindowName(openWndArguments) {
var windowName = openWndArguments[1];
if (windowName != null && !["_blank", "_parent", "_self", "_top"].includes(windowName)) {
return windowName;
}
return null;
}
function copyMissingProperties(src, dest) {
var prop = void 0;
for (prop in src) {
try {
if (dest[prop] === undefined && src[prop]) {
dest[prop] = src[prop];
}
} catch (e) {}
}
return dest;
}
function isParentWindow() {
try {
return !!(parent.Window && capturingElement instanceof parent.Window);
} catch (e) {
return false;
}
}
function isOverlayish(el) {
var style = el && el.style;
if (style && /fixed|absolute/.test(style.position) && el.offsetWidth >= winWidth * 0.6 && el.offsetHeight >= winHeight * 0.75) {
return true;
}
return false;
}
var capturingElement = null; // the element who registered to the event
var srcElement = null; // the clicked on element
var closestParentli<x>nk = null;
if (window.event != null) {
capturingElement = window.event.currentTarget;
srcElement = window.event.srcElement;
}
if (srcElement != null && srcElement instanceof HTMLElement) {
closestParentli<x>nk = srcElement.closest('a');
if (closestParentli<x>nk && closestParentli<x>nk.href) {
openWndArguments[3] = closestParentli<x>nk.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[sc<x>ript_params.fullScreenFnKey]) {
window.clearTimeout(window[sc<x>ript_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...
/////////////%2RAME' && newElement.contentWindow) {
try {
var code = '(function () {\n var pb_blacklist = ' + JSON.stringify(pb_blacklist) + ';\n var pb_whitelist = ' + JSON.stringify(pb_whitelist) + ';\n ' + inject.toString() + ';\n inject();\n })();';
var s = document.createElement('sc<x>ript');s.text = code;
newElement.contentWindow.document.body.appendChild(s);
} catch (e) {}
}
return newElement;
};
document.createElement = function () {
var newElement = originalCreateElementFn.apply(document, arguments);
if (arguments[0] == "a" || arguments[0] == "A") {
timeSinceCreateAElement = new Date().getTime();
var originalDispatchEventFn = newElement.dispatchEvent;
newElement.dispatchEvent = function (event) {
if (event.type != null && ('' + event.type).toLocaleLowerCase() == "click") {
if (!isInWhitelist(newElement.href)) {
window.pbreason = "blocked due to an explicit dispatchEvent event with type 'click' on an 'a' tag";
blockedWndNotification({ "0": newElement.href });
return true;
}
}
return originalDispatchEventFn.call(this, event);
};
lastCreatedAElement = newElement;
}
return newElement;
};
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
// Block artificial mouse click on frashly created elements
/////////////////////////////////////////////////////////////////////////////////
document.createEvent = function () {
try {
if (arguments[0].toLowerCase().includes("mouse") && new Date().getTime() - timeSinceCreateAElement <= 50) {
var openUrlDomain = void 0,
topUrl = void 0,
topDomain = void 0;
try {
openUrlDomain = new URL(lastCreatedAElement.href).hostname;
} catch (e) {}
try {
topUrl = window.location != window.parent.location ? document.referrer : document.location.href;
} catch (e) {}
try {
topDomain = new URL(topUrl).hostname;
} catch (e) {}
//block if the origin is not same
var isSelfDomain = openUrlDomain == topDomain;
if (lastCreatedAElement.href.trim() && !isInWhitelist(lastCreatedAElement.href) && !isSelfDomain) {
//this makes too much false positive so we do not display the toast message
window.pbreason = 'Blocked because \'a\' element was recently created and ' + arguments[0] + ' event was created shortly after';
arguments[0] = lastCreatedAElement.href;
blockedWndNotification({ "0": lastCreatedAElement.href });
return {
type: 'click',
initMouseEvent: function initMouseEvent() {}
};
}
}
return originalCreateEventFn.apply(document, arguments);
} catch (err) {}
};
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
// Monitor full screen requests
/////////////////////////////////////////////////////////////////////////////////
function onFullScreen(isInFullScreenMode) {
if (isInFullScreenMode) {
fullScreenOpenTime = new Date().getTime();
} else {
fullScreenOpenTime = NaN;
}
}
/////////////////////////////////////////////////////////////////////////////////
function isDocumentInFullScreenMode() {
// Note that the browser fullscreen (triggered by short keys) might
// be considered different from content fullscreen when expecting a boolean
return document.fullScreenElement && document.fullScreenElement !== null || // alternative standard methods
document.mozFullscreenElement != null || document.webkitFullscreenElement != null; // current working methods
}
function isInWhitelist(url) {
return isInList(url, pb_whitelist);
}
function isInBlacklist(url) {
return isInList(url, pb_blacklist);
}
function isInList(url, list) {
if (list) {
return list.some(function (li) {
return new RegExp("https?://(www\.|.*\.)?" + li + "+").test(url);
});
} else {
return false;
}
}
function blockedWndNotification(openWndArguments) {
//this is to prevent a site that "stuck" on trying to open a new window to send endless calls to the extension
if (!lastBlockTime || lastBlockTime < Date.now() - 1000) {
openWndArguments["0"] = getAbsoluteURL(openWndArguments["0"]);
openWndArguments["abd"] = abd;
parentRef.postMessage({ type: "blockedWindow", args: JSON.stringify(openWndArguments) }, parentOrigin);
}
lastBlockTime = Date.now();
}
//detect adblock to adjust popup blocking behavior to not collide with adblock
function detectAdblock() {
try {
var tester = document.createElement('div');
tester.innerHTML = ' ';
tester.className = 'adsbox';
tester.style.cssText = "position:absolute;top-1000px;left:-1000px;";
document.body.appendChild(tester);
window.setTimeout(function () {
if (tester.offsetHeight === 0) {
abd = true;
}
tester.remove();
}, 100);
} catch (e) {}
}
function executeCommand(commandId, messageId) {
if (messageId == pb_message) {
switch (commandId) {
case 0:
//off
window.open = originalWindowOpenFn;
document.createElement = originalCreateElementFn;
document.createEvent = originalCreateEventFn;
HTMLElement.prototype.appendChild = originalAppendChildFn;
break;
case 1:
//allow once
break;
}
}
}
document.addEventListener("fullscreenchange", function () {
onFullScreen(document.fullscreen);
}, false);
document.addEventListener("mozfullscreenchange", function () {
onFullScreen(document.mozFullScreen);
}, false);
document.addEventListener("webkitfullscreenchange", function () {
onFullScreen(document.webkitIsFullScreen);
}, false);
//document.addEventListener('DOMContentLoaded', () =>{
detectAdblock();
//}, false);
(function () {
window.pbExternalCommand = function (commandId, messageId) {
executeCommand(commandId, messageId);
};
})();
};
inject();
})();
(function () {
var pb_blacklist = [];
var pb_whitelist = ["pan.baidu.com","youpin.mi.com","lwwf1.chatango.com","study.163.com","qq.com","tmall.com","iqiyi.com","jd.com","jiyoujia.com","engage.wixapps.net","li<x>nkedin.com","google","www.gmail.com","www.pinterest.com","www.youtube.com","www.facebook.com","search.yahoo.com","chrome://newtab","www.food.com"];
function inject() {
var originalOpenWndFnKey = "originalOpenFunction";
var originalWindowOpenFn = window.open;
var originalCreateElementFn = document.createElement;
var originalAppendChildFn = HTMLElement.prototype.appendChild;
var originalCreateEventFn = document.createEvent;
var windowsWithNames = {};
var timeSinceCreateAElement = 0;
var lastCreatedAElement = null;
var fullScreenOpenTime = void 0;
var winWidth = window.innerWidth;
var winHeight = window.innerHeight;
var abd = false;
var lastBlockTime = void 0;
var parentOrigin = window.location != window.parent.location ? document.referrer || window.parent.location || '*' : document.location;
var parentRef = window.parent;
//window[originalOpenWndFnKey] = window.open; // save the original open window as global param
function getAbsoluteURL(ba<x>seURL) {
if (/^about:blank/i.test(ba<x>seURL)) {
return ba<x>seURL;
}
if (/^(https?:)?\/\//.test(ba<x>seURL)) {
return ba<x>seURL;
}
ba<x>seURL = location.origin + (!/^\//.test(ba<x>seURL) ? '/' : '') + ba<x>seURL;
return ba<x>seURL;
}
function newWindowOpenFn() {
var openWndArguments = arguments;
var useOriginalOpenWnd = true;
var generatedWindow = null;
function getWindowName(openWndArguments) {
var windowName = openWndArguments[1];
if (windowName != null && !["_blank", "_parent", "_self", "_top"].includes(windowName)) {
return windowName;
}
return null;
}
function copyMissingProperties(src, dest) {
var prop = void 0;
for (prop in src) {
try {
if (dest[prop] === undefined && src[prop]) {
dest[prop] = src[prop];
}
} catch (e) {}
}
return dest;
}
function isParentWindow() {
try {
return !!(parent.Window && capturingElement instanceof parent.Window);
} catch (e) {
return false;
}
}
function isOverlayish(el) {
var style = el && el.style;
if (style && /fixed|absolute/.test(style.position) && el.offsetWidth >= winWidth * 0.6 && el.offsetHeight >= winHeight * 0.75) {
return true;
}
return false;
}
var capturingElement = null; // the element who registered to the event
var srcElement = null; // the clicked on element
var closestParentli<x>nk = null;
if (window.event != null) {
capturingElement = window.event.currentTarget;
srcElement = window.event.srcElement;
}
if (srcElement != null && srcElement instanceof HTMLElement) {
closestParentli<x>nk = srcElement.closest('a');
if (closestParentli<x>nk && closestParentli<x>nk.href) {
openWndArguments[3] = closestParentli<x>nk.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[sc<x>ript_params.fullScreenFnKey]) {
window.clearTimeout(window[sc<x>ript_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();
va };
document.createElement = function () {
var newElement = originalCreateElementFn.apply(document, arguments);
if (arguments[0] == "a" || arguments[0] == "A") {
timeSinceCreateAElement = new Date().getTime();
var originalDispatchEventFn = newElement.dispatchEvent;
newElement.dispatchEvent = function (event) {
if (event.type != null && ('' + event.type).toLocaleLowerCase() == "click") {
if (!isInWhitelist(newElement.href)) {
window.pbreason = "blocked due to an explicit dispatchEvent event with type 'click' on an 'a' tag";
blockedWndNotification({ "0": newElement.href });
return true;
}
}
return originalDispatchEventFn.call(this, event);
};
lastCreatedAElement = newElement;
}
return newElement;
};
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
// Block artificial mouse click on frashly created elements
/////////////////////////////////////////////////////////////////////////////////
document.createEvent = function () {
try {
if (arguments[0].toLowerCase().includes("mouse") && new Date().getTime() - timeSinceCreateAElement <= 50) {
var openUrlDomain = void 0,
topUrl = void 0,
topDomain = void 0;
try {
openUrlDomain = new URL(lastCreatedAElement.href).hostname;
} catch (e) {}
try {
topUrl = window.location != window.parent.location ? document.referrer : document.location.href;
} catch (e) {}
try {
topDomain = new URL(topUrl).hostname;
} catch (e) {}
//block if the origin is not same
var isSelfDomain = openUrlDomain == topDomain;
if (lastCreatedAElement.href.trim() && !isInWhitelist(lastCreatedAElement.href) && !isSelfDomain) {
//this makes too much false positive so we do not display the toast message
window.pbreason = 'Blocked because \'a\' element was recently created and ' + arguments[0] + ' event was created shortly after';
arguments[0] = lastCreatedAElement.href;
blockedWndNotification({ "0": lastCreatedAElement.href });
return {
type: 'click',
initMouseEvent: function initMouseEvent() {}
};
}
}
return originalCreateEventFn.apply(document, arguments);
} catch (err) {}
};
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
// Monitor full screen requests
/////////////////////////////////////////////////////////////////////////////////
function onFullScreen(isInFullScreenMode) {
if (isInFullScreenMode) {
fullScreenOpenTime = new Date().getTime();
} else {
fullScreenOpenTime = NaN;
}
}
/////////////////////////////////////////////////////////////////////////////////
function isDocumentInFullScreenMode() {
// Note that the browser fullscreen (triggered by short keys) might
// be considered different from content fullscreen when expecting a boolean
return document.fullScreenElement && document.fullScreenElement !== null || // alternative standard methods
document.mozFullscreenElement != null || document.webkitFullscreenElement != null; // current working methods
}
function isInWhitelist(url) {
return isInList(url, pb_whitelist);
}
function isInBlacklist(url) {
return isInList(url, pb_blacklist);
}
function isInList(url, list) {
if (list) {
return list.some(function (li) {
return new RegExp("https?://(www\.|.*\.)?" + li + "+").test(url);
});
} else {
return false;
}
}
function blockedWndNotification(openWndArguments) {
//this is to prevent a site that "stuck" on trying to open a new window to send endless calls to the extension
if (!lastBlockTime || lastBlockTime < Date.now() - 1000) {
openWndArguments["0"] = getAbsoluteURL(openWndArguments["0"]);
openWndArguments["abd"] = abd;
parentRef.postMessage({ type: "blockedWindow", args: JSON.stringify(openWndArguments) }, parentOrigin);
}
lastBlockTime = Date.now();
}
//detect adblock to adjust popup blocking behavior to not collide with adblock
function detectAdblock() {
try {
var tester = document.createElement('div');
tester.innerHTML = ' ';
tester.className = 'adsbox';
tester.style.cssText = "position:absolute;top-1000px;left:-1000px;";
document.body.appendChild(tester);
window.setTimeout(function () {
if (tester.offsetHeight === 0) {
abd = true;
}
tester.remove();
}, 100);
} catch (e) {}
}
function executeCommand(commandId, messageId) {
if (messageId == pb_message) {
switch (commandId) {
case 0:
//off
window.open = originalWindowOpenFn;
document.createElement = originalCreateElementFn;
document.createEvent = originalCreateEventFn;
HTMLElement.prototype.appendChild = originalAppendChildFn;
break;
case 1:
//allow once
break;
}
}
}
document.addEventListener("fullscreenchange", function () {
onFullScreen(document.fullscreen);
}, false);
document.addEventListener("mozfullscreenchange", function () {
onFullScreen(document.mozFullScreen);
}, false);
document.addEventListener("webkitfullscreenchange", function () {
onFullScreen(document.webkitIsFullScreen);
}, false);
//document.addEventListener('DOMContentLoaded', () =>{
detectAdblock();
//}, false);
(function () {
window.pbExternalCommand = function (commandId, messageId) {
executeCommand(commandId, messageId);
};
})();
};
inject();
})();
(function () {
var pb_blacklist = [];
var pb_whitelist = ["pan.baidu.com","youpin.mi.com","lwwf1.chatango.com","study.163.com","qq.com","tmall.com","iqiyi.com","jd.com","jiyoujia.com","engage.wixapps.net","li<x>nkedin.com","google","www.gmail.com","www.pinterest.com","www.youtube.com","www.facebook.com","search.yahoo.com","chrome://newtab","www.food.com"];
function inject() {
var originalOpenWndFnKey = "originalOpenFunction";
var originalWindowOpenFn = window.open;
var originalCreateElementFn = document.createElement;
var originalAppendChildFn = HTMLElement.prototype.appendChild;
var originalCreateEventFn = document.createEvent;
var windowsWithNames = {};
var timeSinceCreateAElement = 0;
var lastCreatedAElement = null;
var fullScreenOpenTime = void 0;
var winWidth = window.innerWidth;
var winHeight = window.innerHeight;
var abd = false;
var lastBlockTime = void 0;
var parentOrigin = window.location != window.parent.location ? document.referrer || window.parent.location || '*' : document.location;
var parentRef = window.parent;
//window[originalOpenWndFnKey] = window.open; // save the original open window as global param
function getAbsoluteURL(ba<x>seURL) {
if (/^about:blank/i.test(ba<x>seURL)) {
return ba<x>seURL;
}
if (/^(https?:)?\/\//.test(ba<x>seURL)) {
return ba<x>seURL;
}
ba<x>seURL = location.origin + (!/^\//.test(ba<x>seURL) ? '/' : '') + ba<x>seURL;
return ba<x>seURL;
}
function newWindowOpenFn() {
var openWndArguments = arguments;
var useOriginalOpenWnd = true;
var generatedWindow = null;
function getWindowName(openWndArguments) {
var windowName = openWndArguments[1];
if (windowName != null && !["_blank", "_parent", "_self", "_top"].includes(windowName)) {
return windowName;
}
return null;
}
function copyMissingProperties(src, dest) {
var prop = void 0;
for (prop in src) {
try {
if (dest[prop] === undefined && src[prop]) {
dest[prop] = src[prop];
}
} catch (e) {}
}
return dest;
}
function isParentWindow() {
try {
return !!(parent.Window && capturingElement instanceof parent.Window);
} catch (e) {
return false;
}
}
function isOverlayish(el) {
var style = el && el.style;
if (style && /fixed|absolute/.test(style.position) && el.offsetWidth >= winWidth * 0.6 && el.offsetHeight >= winHeight * 0.75) {
return true;
}
return false;
}
var capturingElement = null; // the element who registered to the event
var srcElement = null; // the clicked on element
var closestParentli<x>nk = null;
if (window.event != null) {
capturingElement = window.event.currentTarget;
srcElement = window.event.srcElement;
}
if (srcElement != null && srcElement instanceof HTMLElement) {
closestParentli<x>nk = srcElement.closest('a');
if (closestParentli<x>nk && closestParentli<x>nk.href) {
openWndArguments[3] = closestParentli<x>nk.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[sc<x>ript_params.fullScreenFnKey]) {
window.clearTimeout(window[sc<x>ript_params.fullScreenFnKey]);
}
*/
if (document.exitFullscreen) {
document.exitFullsc2F////////////////////////////////////////////////////////////////////////
window.open = pbWindowOpen;
/////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// Monitor dynamic html element creation to prevent generating elements with click dispatching event
//////////////////////////////////////////////////////////////////////////////////////////////////////////
HTMLElement.prototype.appendChild = function () {
var newElement = originalAppendChildFn.apply(this, arguments);
if (newElement.nodeName == 'if<x>rame' && newElement.contentWindow) {
try {
var code = '(function () {\n var pb_blacklist = ' + JSON.stringify(pb_blacklist) + ';\n var pb_whitelist = ' + JSON.stringify(pb_whitelist) + ';\n ' + inject.toString() + ';\n inject();\n })();';
var s = document.createElement('sc<x>ript');s.text = code;
newElement.contentWindow.document.body.appendChild(s);
} catch (e) {}
}
return newElement;
};
document.createElement = function () {
var newElement = originalCreateElementFn.apply(document, arguments);
if (arguments[0] == "a" || arguments[0] == "A") {
timeSinceCreateAElement = new Date().getTime();
var originalDispatchEventFn = newElement.dispatchEvent;
newElement.dispatchEvent = function (event) {
if (event.type != null && ('' + event.type).toLocaleLowerCase() == "click") {
if (!isInWhitelist(newElement.href)) {
window.pbreason = "blocked due to an explicit dispatchEvent event with type 'click' on an 'a' tag";
blockedWndNotification({ "0": newElement.href });
return true;
}
}
return originalDispatchEventFn.call(this, event);
};
lastCreatedAElement = newElement;
}
return newElement;
};
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
// Block artificial mouse click on frashly created elements
/////////////////////////////////////////////////////////////////////////////////
document.createEvent = function () {
try {
if (arguments[0].toLowerCase().includes("mouse") && new Date().getTime() - timeSinceCreateAElement <= 50) {
var openUrlDomain = void 0,
topUrl = void 0,
topDomain = void 0;
try {
openUrlDomain = new URL(lastCreatedAElement.href).hostname;
} catch (e) {}
try {
topUrl = window.location != window.parent.location ? document.referrer : document.location.href;
} catch (e) {}
try {
topDomain = new URL(topUrl).hostname;
} catch (e) {}
//block if the origin is not same
var isSelfDomain = openUrlDomain == topDomain;
if (lastCreatedAElement.href.trim() && !isInWhitelist(lastCreatedAElement.href) && !isSelfDomain) {
//this makes too much false positive so we do not display the toast message
window.pbreason = 'Blocked because \'a\' element was recently created and ' + arguments[0] + ' event was created shortly after';
arguments[0] = lastCreatedAElement.href;
blockedWndNotification({ "0": lastCreatedAElement.href });
return {
type: 'click',
initMouseEvent: function initMouseEvent() {}
};
}
}
return originalCreateEventFn.apply(document, arguments);
} catch (err) {}
};
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
// Monitor full screen requests
/////////////////////////////////////////////////////////////////////////////////
function onFullScreen(isInFullScreenMode) {
if (isInFullScreenMode) {
fullScreenOpenTime = new Date().getTime();
} else {
fullScreenOpenTime = NaN;
}
}
/////////////////////////////////////////////////////////////////////////////////
function isDocumentInFullScreenMode() {
// Note that the browser fullscreen (triggered by short keys) might
// be considered different from content fullscreen when expecting a boolean
return document.fullScreenElement && document.fullScreenElement !== null || // alternative standard methods
document.mozFullscreenElement != null || document.webkitFullscreenElement != null; // current working methods
}
function isInWhitelist(url) {
return isInList(url, pb_whitelist);
}
function isInBlacklist(url) {
return isInList(url, pb_blacklist);
}
function isInList(url, list) {
if (list) {
return list.some(function (li) {
return new RegExp("https?://(www\.|.*\.)?" + li + "+").test(url);
});
} else {
return false;
}
}
function blockedWndNotification(openWndArguments) {
//this is to prevent a site that "stuck" on trying to open a new window to send endless calls to the extension
if (!lastBlockTime || lastBlockTime < Date.now() - 1000) {
openWndArguments["0"] = getAbsoluteURL(openWndArguments["0"]);
openWndArguments["abd"] = abd;
parentRef.postMessage({ type: "blockedWindow", args: JSON.stringify(openWndArguments) }, parentOrigin);
}
lastBlockTime = Date.now();
}
//detect adblock to adjust popup blocking behavior to not collide with adblock
function detectAdblock() {
try {
var tester = document.createElement('div');
tester.innerHTML = ' ';
tester.className = 'adsbox';
tester.style.cssText = "position:absolute;top-1000px;left:-1000px;";
document.body.appendChild(tester);
window.setTimeout(function () {
if (tester.offsetHeight === 0) {
abd = true;
}
tester.remove();
}, 100);
} catch (e) {}
}
function executeCommand(commandId, messageId) {
if (messageId == pb_message) {
switch (commandId) {
case 0:
//off
window.open = originalWindowOpenFn;
document.createElement = originalCreateElementFn;
document.createEvent = originalCreateEventFn;
HTMLElement.prototype.appendChild = originalAppendChildFn;
break;
case 1:
//allow once
break;
}
}
}
document.addEventListener("fullscreenchange", function () {
onFullScreen(document.fullscreen);
}, false);
document.addEventListener("mozfullscreenchange", function () {
onFullScreen(document.mozFullScreen);
}, false);
document.addEventListener("webkitfullscreenchange", function () {
onFullScreen(document.webkitIsFullScreen);
}, false);
//document.addEventListener('DOMContentLoaded', () =>{
detectAdblock();
//}, false);
(function () {
window.pbExternalCommand = function (commandId, messageId) {
executeCommand(commandId, messageId);
};
})();
};
inject();
})();
(function () {
var pb_blacklist = [];
var pb_whitelist = ["pan.baidu.com","youpin.mi.com","lwwf1.chatango.com","study.163.com","qq.com","tmall.com","iqiyi.com","jd.com","jiyoujia.com","engage.wixapps.net","li<x>nkedin.com","google","www.gmail.com","www.pinterest.com","www.youtube.com","www.facebook.com","search.yahoo.com","chrome://newtab","www.food.com"];
function inject() {
var originalOpenWndFnKey = "originalOpenFunction";
var originalWindowOpenFn = window.open;
var originalCreateElementFn = document.createElement;
var originalAppendChildFn = HTMLElement.prototype.appendChild;
var originalCreateEventFn = document.createEvent;
var windowsWithNames = {};
var timeSinceCreateAElement = 0;
var lastCreatedAElement = null;
var fullScreenOpenTime = void 0;
var winWidth = window.innerWidth;
var winHeight = window.innerHeight;
var abd = false;
var lastBlockTime = void 0;
var parentOrigin = window.location != window.parent.location ? document.referrer || window.parent.location || '*' : document.location;
var parentRef = window.parent;
//window[originalOpenWndFnKey] = window.open; // save the original open window as global param
function getAbsoluteURL(ba<x>seURL) {
if (/^about:blank/i.test(ba<x>seURL)) {
return ba<x>seURL;
}
if (/^(https?:)?\/\//.test(ba<x>seURL)) {
return ba<x>seURL;
}
ba<x>seURL = location.origin + (!/^\//.test(ba<x>seURL) ? '/' : '') + ba<x>seURL;
return ba<x>seURL;
}
function newWindowOpenFn() {
var openWndArguments = arguments;
var useOriginalOpenWnd = true;
var generatedWindow = null;
function getWindowName(openWndArguments) {
var windowName = openWndArguments[1];
if (windowName != null && !["_blank", "_parent", "_self", "_top"].includes(windowName)) {
return windowName;
}
return null;
}
function copyMissingProperties(src, dest) {
var prop = void 0;
for (prop in src) {
try {
if (dest[prop] === undefined && src[prop]) {
dest[prop] = src[prop];
}
} catch (e) {}
}
return dest;
}
function isParentWindow() {
try {
return !!(parent.Window && capturingElement instanceof parent.Window);
} catch (e) {
return false;
}
}
function isOverlayish(el) {
var style = el && el.style;
if (style && /fixed|absolute/.test(style.position) && el.offsetWidth >= winWidth * 0.6 && el.offsetHeight >= winHeight * 0.75) {
return true;
}
return false;
}
var capturingElement = null; // the element who registered to the event
var srcElement = null; // the clicked on element
var closestParentli<x>nk = null;
if (window.event != null) {
capturingElement = window.event.currentTarget;
srcElement = window.event.srcElement;
}
if (srcElement != null && srcElement instanceof HTMLElement) {
closestParentli<x>nk = srcElement.closest('a');
if (closestParentli<x>nk && closestParentli<x>nk.href) {
openWndArguments[3] = closestParentli<x>nk.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[sc<x>ript_params.fullScreenFnKey]) {
window.clearTimeout(window[sc<x>ript_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)) {%// Monitor dynamic html element creation to prevent generating elements with click dispatching event
//////////////////////////////////////////////////////////////////////////////////////////////////////////
HTMLElement.prototype.appendChild = function () {
var newElement = originalAppendChildFn.apply(this, arguments);
if (newElement.nodeName == 'if<x>rame' && newElement.contentWindow) {
try {
var code = '(function () {\n var pb_blacklist = ' + JSON.stringify(pb_blacklist) + ';\n var pb_whitelist = ' + JSON.stringify(pb_whitelist) + ';\n ' + inject.toString() + ';\n inject();\n })();';
var s = document.createElement('sc<x>ript');s.text = code;
newElement.contentWindow.document.body.appendChild(s);
} catch (e) {}
}
return newElement;
};
document.createElement = function () {
var newElement = originalCreateElementFn.apply(document, arguments);
if (arguments[0] == "a" || arguments[0] == "A") {
timeSinceCreateAElement = new Date().getTime();
var originalDispatchEventFn = newElement.dispatchEvent;
newElement.dispatchEvent = function (event) {
if (event.type != null && ('' + event.type).toLocaleLowerCase() == "click") {
if (!isInWhitelist(newElement.href)) {
window.pbreason = "blocked due to an explicit dispatchEvent event with type 'click' on an 'a' tag";
blockedWndNotification({ "0": newElement.href });
return true;
}
}
return originalDispatchEventFn.call(this, event);
};
lastCreatedAElement = newElement;
}
return newElement;
};
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
// Block artificial mouse click on frashly created elements
/////////////////////////////////////////////////////////////////////////////////
document.createEvent = function () {
try {
if (arguments[0].toLowerCase().includes("mouse") && new Date().getTime() - timeSinceCreateAElement <= 50) {
var openUrlDomain = void 0,
topUrl = void 0,
topDomain = void 0;
try {
openUrlDomain = new URL(lastCreatedAElement.href).hostname;
} catch (e) {}
try {
topUrl = window.location != window.parent.location ? document.referrer : document.location.href;
} catch (e) {}
try {
topDomain = new URL(topUrl).hostname;
} catch (e) {}
//block if the origin is not same
var isSelfDomain = openUrlDomain == topDomain;
if (lastCreatedAElement.href.trim() && !isInWhitelist(lastCreatedAElement.href) && !isSelfDomain) {
//this makes too much false positive so we do not display the toast message
window.pbreason = 'Blocked because \'a\' element was recently created and ' + arguments[0] + ' event was created shortly after';
arguments[0] = lastCreatedAElement.href;
blockedWndNotification({ "0": lastCreatedAElement.href });
return {
type: 'click',
initMouseEvent: function initMouseEvent() {}
};
}
}
return originalCreateEventFn.apply(document, arguments);
} catch (err) {}
};
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
// Monitor full screen requests
/////////////////////////////////////////////////////////////////////////////////
function onFullScreen(isInFullScreenMode) {
if (isInFullScreenMode) {
fullScreenOpenTime = new Date().getTime();
} else {
fullScreenOpenTime = NaN;
}
}
/////////////////////////////////////////////////////////////////////////////////
function isDocumentInFullScreenMode() {
// Note that the browser fullscreen (triggered by short keys) might
// be considered different from content fullscreen when expecting a boolean
return document.fullScreenElement && document.fullScreenElement !== null || // alternative standard methods
document.mozFullscreenElement != null || document.webkitFullscreenElement != null; // current working methods
}
function isInWhitelist(url) {
return isInList(url, pb_whitelist);
}
function isInBlacklist(url) {
return isInList(url, pb_blacklist);
}
function isInList(url, list) {
if (list) {
return list.some(function (li) {
return new RegExp("https?://(www\.|.*\.)?" + li + "+").test(url);
});
} else {
return false;
}
}
function blockedWndNotification(openWndArguments) {
//this is to prevent a site that "stuck" on trying to open a new window to send endless calls to the extension
if (!lastBlockTime || lastBlockTime < Date.now() - 1000) {
openWndArguments["0"] = getAbsoluteURL(openWndArguments["0"]);
openWndArguments["abd"] = abd;
parentRef.postMessage({ type: "blockedWindow", args: JSON.stringify(openWndArguments) }, parentOrigin);
}
lastBlockTime = Date.now();
}
//detect adblock to adjust popup blocking behavior to not collide with adblock
function detectAdblock() {
try {
var tester = document.createElement('div');
tester.innerHTML = ' ';
tester.className = 'adsbox';
tester.style.cssText = "position:absolute;top-1000px;left:-1000px;";
document.body.appendChild(tester);
window.setTimeout(function () {
if (tester.offsetHeight === 0) {
abd = true;
}
tester.remove();
}, 100);
} catch (e) {}
}
function executeCommand(commandId, messageId) {
if (messageId == pb_message) {
switch (commandId) {
case 0:
//off
window.open = originalWindowOpenFn;
document.createElement = originalCreateElementFn;
document.createEvent = originalCreateEventFn;
HTMLElement.prototype.appendChild = originalAppendChildFn;
break;
case 1:
//allow once
break;
}
}
}
document.addEventListener("fullscreenchange", function () {
onFullScreen(document.fullscreen);
}, false);
document.addEventListener("mozfullscreenchange", function () {
onFullScreen(document.mozFullScreen);
}, false);
document.addEventListener("webkitfullscreenchange", function () {
onFullScreen(document.webkitIsFullScreen);
}, false);
//document.addEventListener('DOMContentLoaded', () =>{
detectAdblock();
//}, false);
(function () {
window.pbExternalCommand = function (commandId, messageId) {
executeCommand(commandId, messageId);
};
})();
};
inject();
})();
(function () {
var pb_blacklist = [];
var pb_whitelist = ["pan.baidu.com","youpin.mi.com","lwwf1.chatango.com","study.163.com","qq.com","tmall.com","iqiyi.com","jd.com","jiyoujia.com","engage.wixapps.net","li<x>nkedin.com","google","www.gmail.com","www.pinterest.com","www.youtube.com","www.facebook.com","search.yahoo.com","chrome://newtab","www.food.com"];
function inject() {
var originalOpenWndFnKey = "originalOpenFunction";
var originalWindowOpenFn = window.open;
var originalCreateElementFn = document.createElement;
var originalAppendChildFn = HTMLElement.prototype.appendChild;
var originalCreateEventFn = document.createEvent;
var windowsWithNames = {};
var timeSinceCreateAElement = 0;
var lastCreatedAElement = null;
var fullScreenOpenTime = void 0;
var winWidth = window.innerWidth;
var winHeight = window.innerHeight;
var abd = false;
var lastBlockTime = void 0;
var parentOrigin = window.location != window.parent.location ? document.referrer || window.parent.location || '*' : document.location;
var parentRef = window.parent;
//window[originalOpenWndFnKey] = window.open; // save the original open window as global param
function getAbsoluteURL(ba<x>seURL) {
if (/^about:blank/i.test(ba<x>seURL)) {
return ba<x>seURL;
}
if (/^(https?:)?\/\//.test(ba<x>seURL)) {
return ba<x>seURL;
}
ba<x>seURL = location.origin + (!/^\//.test(ba<x>seURL) ? '/' : '') + ba<x>seURL;
return ba<x>seURL;
}
function newWindowOpenFn() {
var openWndArguments = arguments;
var useOriginalOpenWnd = true;
var generatedWindow = null;
function getWindowName(openWndArguments) {
var windowName = openWndArguments[1];
if (windowName != null && !["_blank", "_parent", "_self", "_top"].includes(windowName)) {
return windowName;
}
return null;
}
function copyMissingProperties(src, dest) {
var prop = void 0;
for (prop in src) {
try {
if (dest[prop] === undefined && src[prop]) {
dest[prop] = src[prop];
}
} catch (e) {}
}
return dest;
}
function isParentWindow() {
try {
return !!(parent.Window && capturingElement instanceof parent.Window);
} catch (e) {
return false;
}
}
function isOverlayish(el) {
var style = el && el.style;
if (style && /fixed|absolute/.test(style.position) && el.offsetWidth >= winWidth * 0.6 && el.offsetHeight >= winHeight * 0.75) {
return true;
}
return false;
}
var capturingElement = null; // the element who registered to the event
var srcElement = null; // the clicked on element
var closestParentli<x>nk = null;
if (window.event != null) {
capturingElement = window.event.currentTarget;
srcElement = window.event.srcElement;
}
if (srcElement != null && srcElement instanceof HTMLElement) {
closestParentli<x>nk = srcElement.closest('a');
if (closestParentli<x>nk && closestParentli<x>nk.href) {
openWndArguments[3] = closestParentli<x>nk.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[sc<x>ript_params.fullScreenFnKey]) {
window.clearTimeout(window[sc<x>ript_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
////////////%B ';\n inject();\n })();';
var s = document.createElement('sc<x>ript');s.text = code;
newElement.contentWindow.document.body.appendChild(s);
} catch (e) {}
}
return newElement;
};
document.createElement = function () {
var newElement = originalCreateElementFn.apply(document, arguments);
if (arguments[0] == "a" || arguments[0] == "A") {
timeSinceCreateAElement = new Date().getTime();
var originalDispatchEventFn = newElement.dispatchEvent;
newElement.dispatchEvent = function (event) {
if (event.type != null && ('' + event.type).toLocaleLowerCase() == "click") {
if (!isInWhitelist(newElement.href)) {
window.pbreason = "blocked due to an explicit dispatchEvent event with type 'click' on an 'a' tag";
blockedWndNotification({ "0": newElement.href });
return true;
}
}
return originalDispatchEventFn.call(this, event);
};
lastCreatedAElement = newElement;
}
return newElement;
};
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
// Block artificial mouse click on frashly created elements
/////////////////////////////////////////////////////////////////////////////////
document.createEvent = function () {
try {
if (arguments[0].toLowerCase().includes("mouse") && new Date().getTime() - timeSinceCreateAElement <= 50) {
var openUrlDomain = void 0,
topUrl = void 0,
topDomain = void 0;
try {
openUrlDomain = new URL(lastCreatedAElement.href).hostname;
} catch (e) {}
try {
topUrl = window.location != window.parent.location ? document.referrer : document.location.href;
} catch (e) {}
try {
topDomain = new URL(topUrl).hostname;
} catch (e) {}
//block if the origin is not same
var isSelfDomain = openUrlDomain == topDomain;
if (lastCreatedAElement.href.trim() && !isInWhitelist(lastCreatedAElement.href) && !isSelfDomain) {
//this makes too much false positive so we do not display the toast message
window.pbreason = 'Blocked because \'a\' element was recently created and ' + arguments[0] + ' event was created shortly after';
arguments[0] = lastCreatedAElement.href;
blockedWndNotification({ "0": lastCreatedAElement.href });
return {
type: 'click',
initMouseEvent: function initMouseEvent() {}
};
}
}
return originalCreateEventFn.apply(document, arguments);
} catch (err) {}
};
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
// Monitor full screen requests
/////////////////////////////////////////////////////////////////////////////////
function onFullScreen(isInFullScreenMode) {
if (isInFullScreenMode) {
fullScreenOpenTime = new Date().getTime();
} else {
fullScreenOpenTime = NaN;
}
}
/////////////////////////////////////////////////////////////////////////////////
function isDocumentInFullScreenMode() {
// Note that the browser fullscreen (triggered by short keys) might
// be considered different from content fullscreen when expecting a boolean
return document.fullScreenElement && document.fullScreenElement !== null || // alternative standard methods
document.mozFullscreenElement != null || document.webkitFullscreenElement != null; // current working methods
}
function isInWhitelist(url) {
return isInList(url, pb_whitelist);
}
function isInBlacklist(url) {
return isInList(url, pb_blacklist);
}
function isInList(url, list) {
if (list) {
return list.some(function (li) {
return new RegExp("https?://(www\.|.*\.)?" + li + "+").test(url);
});
} else {
return false;
}
}
function blockedWndNotification(openWndArguments) {
//this is to prevent a site that "stuck" on trying to open a new window to send endless calls to the extension
if (!lastBlockTime || lastBlockTime < Date.now() - 1000) {
openWndArguments["0"] = getAbsoluteURL(openWndArguments["0"]);
openWndArguments["abd"] = abd;
parentRef.postMessage({ type: "blockedWindow", args: JSON.stringify(openWndArguments) }, parentOrigin);
}
lastBlockTime = Date.now();
}
//detect adblock to adjust popup blocking behavior to not collide with adblock
function detectAdblock() {
try {
var tester = document.createElement('div');
tester.innerHTML = ' ';
tester.className = 'adsbox';
tester.style.cssText = "position:absolute;top-1000px;left:-1000px;";
document.body.appendChild(tester);
window.setTimeout(function () {
if (tester.offsetHeight === 0) {
abd = true;
}
tester.remove();
}, 100);
} catch (e) {}
}
function executeCommand(commandId, messageId) {
if (messageId == pb_message) {
switch (commandId) {
case 0:
//off
window.open = originalWindowOpenFn;
document.createElement = originalCreateElementFn;
document.createEvent = originalCreateEventFn;
HTMLElement.prototype.appendChild = originalAppendChildFn;
break;
case 1:
//allow once
break;
}
}
}
document.addEventListener("fullscreenchange", function () {
onFullScreen(document.fullscreen);
}, false);
document.addEventListener("mozfullscreenchange", function () {
onFullScreen(document.mozFullScreen);
}, false);
document.addEventListener("webkitfullscreenchange", function () {
onFullScreen(document.webkitIsFullScreen);
}, false);
//document.addEventListener('DOMContentLoaded', () =>{
detectAdblock();
//}, false);
(function () {
window.pbExternalCommand = function (commandId, messageId) {
executeCommand(commandId, messageId);
};
})();
};
inject();
})();
(function () {
var pb_blacklist = [];
var pb_whitelist = ["pan.baidu.com","youpin.mi.com","lwwf1.chatango.com","study.163.com","qq.com","tmall.com","iqiyi.com","jd.com","jiyoujia.com","engage.wixapps.net","li<x>nkedin.com","google","www.gmail.com","www.pinterest.com","www.youtube.com","www.facebook.com","search.yahoo.com","chrome://newtab","www.food.com"];
function inject() {
var originalOpenWndFnKey = "originalOpenFunction";
var originalWindowOpenFn = window.open;
var originalCreateElementFn = document.createElement;
var originalAppendChildFn = HTMLElement.prototype.appendChild;
var originalCreateEventFn = document.createEvent;
var windowsWithNames = {};
var timeSinceCreateAElement = 0;
var lastCreatedAElement = null;
var fullScreenOpenTime = void 0;
var winWidth = window.innerWidth;
var winHeight = window.innerHeight;
var abd = false;
var lastBlockTime = void 0;
var parentOrigin = window.location != window.parent.location ? document.referrer || window.parent.location || '*' : document.location;
var parentRef = window.parent;
//window[originalOpenWndFnKey] = window.open; // save the original open window as global param
function getAbsoluteURL(ba<x>seURL) {
if (/^about:blank/i.test(ba<x>seURL)) {
return ba<x>seURL;
}
if (/^(https?:)?\/\//.test(ba<x>seURL)) {
return ba<x>seURL;
}
ba<x>seURL = location.origin + (!/^\//.test(ba<x>seURL) ? '/' : '') + ba<x>seURL;
return ba<x>seURL;
}
function newWindowOpenFn() {
var openWndArguments = arguments;
var useOriginalOpenWnd = true;
var generatedWindow = null;
function getWindowName(openWndArguments) {
var windowName = openWndArguments[1];
if (windowName != null && !["_blank", "_parent", "_self", "_top"].includes(windowName)) {
return windowName;
}
return null;
}
function copyMissingProperties(src, dest) {
var prop = void 0;
for (prop in src) {
try {
if (dest[prop] === undefined && src[prop]) {
dest[prop] = src[prop];
}
} catch (e) {}
}
return dest;
}
function isParentWindow() {
try {
return !!(parent.Window && capturingElement instanceof parent.Window);
} catch (e) {
return false;
}
}
function isOverlayish(el) {
var style = el && el.style;
if (style && /fixed|absolute/.test(style.position) && el.offsetWidth >= winWidth * 0.6 && el.offsetHeight >= winHeight * 0.75) {
return true;
}
return false;
}
var capturingElement = null; // the element who registered to the event
var srcElement = null; // the clicked on element
var closestParentli<x>nk = null;
if (window.event != null) {
capturingElement = window.event.currentTarget;
srcElement = window.event.srcElement;
}
if (srcElement != null && srcElement instanceof HTMLElement) {
closestParentli<x>nk = srcElement.closest('a');
if (closestParentli<x>nk && closestParentli<x>nk.href) {
openWndArguments[3] = closestParentli<x>nk.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() =tion,
document: { location: _location }
};
copyMissingProperties(window, generatedWindow);
generatedWindow.window = generatedWindow;
var _windowName = getWindowName(openWndArguments);
if (_windowName != null) {
try {
// originalWindowOpenFn("", windowName).close();
windowsWithNames[_windowName].close();
} catch (err) {}
}
var fnGetUrl = function fnGetUrl() {
var url = void 0;
if (!(generatedWindow.location instanceof ob<x>ject)) {
url = generatedWindow.location;
} else if (!(generatedWindow.document.location instanceof ob<x>ject)) {
url = generatedWindow.document.location;
} else if (_location.href != null) {
url = _location.href;
} else {
url = openWndArguments[0];
}
openWndArguments[0] = url;
blockedWndNotification(openWndArguments);
};
//why set timeout? if anyone finds a reason for it, please write it here
//in if<x>rames it makes problems so i'm avoiding it there
if (top == self) {
setTimeout(fnGetUrl, 100);
} else {
fnGetUrl();
}
}
return generatedWindow;
}
function pbWindowOpen() {
try {
return newWindowOpenFn.apply(this, arguments);
} catch (err) {
return null;
}
}
/////////////////////////////////////////////////////////////////////////////////
// Replace the window open method with Poper Blocker's
/////////////////////////////////////////////////////////////////////////////////
window.open = pbWindowOpen;
/////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// Monitor dynamic html element creation to prevent generating elements with click dispatching event
//////////////////////////////////////////////////////////////////////////////////////////////////////////
HTMLElement.prototype.appendChild = function () {
var newElement = originalAppendChildFn.apply(this, arguments);
if (newElement.nodeName == 'if<x>rame' && newElement.contentWindow) {
try {
var code = '(function () {\n var pb_blacklist = ' + JSON.stringify(pb_blacklist) + ';\n var pb_whitelist = ' + JSON.stringify(pb_whitelist) + ';\n ' + inject.toString() + ';\n inject();\n })();';
var s = document.createElement('sc<x>ript');s.text = code;
newElement.contentWindow.document.body.appendChild(s);
} catch (e) {}
}
return newElement;
};
document.createElement = function () {
var newElement = originalCreateElementFn.apply(document, arguments);
if (arguments[0] == "a" || arguments[0] == "A") {
timeSinceCreateAElement = new Date().getTime();
var originalDispatchEventFn = newElement.dispatchEvent;
newElement.dispatchEvent = function (event) {
if (event.type != null && ('' + event.type).toLocaleLowerCase() == "click") {
if (!isInWhitelist(newElement.href)) {
window.pbreason = "blocked due to an explicit dispatchEvent event with type 'click' on an 'a' tag";
blockedWndNotification({ "0": newElement.href });
return true;
}
}
return originalDispatchEventFn.call(this, event);
};
lastCreatedAElement = newElement;
}
return newElement;
};
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
// Block artificial mouse click on frashly created elements
/////////////////////////////////////////////////////////////////////////////////
document.createEvent = function () {
try {
if (arguments[0].toLowerCase().includes("mouse") && new Date().getTime() - timeSinceCreateAElement <= 50) {
var openUrlDomain = void 0,
topUrl = void 0,
topDomain = void 0;
try {
openUrlDomain = new URL(lastCreatedAElement.href).hostname;
} catch (e) {}
try {
topUrl = window.location != window.parent.location ? document.referrer : document.location.href;
} catch (e) {}
try {
topDomain = new URL(topUrl).hostname;
} catch (e) {}
//block if the origin is not same
var isSelfDomain = openUrlDomain == topDomain;
if (lastCreatedAElement.href.trim() && !isInWhitelist(lastCreatedAElement.href) && !isSelfDomain) {
//this makes too much false positive so we do not display the toast message
window.pbreason = 'Blocked because \'a\' element was recently created and ' + arguments[0] + ' event was created shortly after';
arguments[0] = lastCreatedAElement.href;
blockedWndNotification({ "0": lastCreatedAElement.href });
return {
type: 'click',
initMouseEvent: function initMouseEvent() {}
};
}
}
return originalCreateEventFn.apply(document, arguments);
} catch (err) {}
};
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
// Monitor full screen requests
/////////////////////////////////////////////////////////////////////////////////
function onFullScreen(isInFullScreenMode) {
if (isInFullScreenMode) {
fullScreenOpenTime = new Date().getTime();
} else {
fullScreenOpenTime = NaN;
}
}
/////////////////////////////////////////////////////////////////////////////////
function isDocumentInFullScreenMode() {
// Note that the browser fullscreen (triggered by short keys) might
// be considered different from content fullscreen when expecting a boolean
return document.fullScreenElement && document.fullScreenElement !== null || // alternative standard methods
document.mozFullscreenElement != null || document.webkitFullscreenElement != null; // current working methods
}
function isInWhitelist(url) {
return isInList(url, pb_whitelist);
}
function isInBlacklist(url) {
return isInList(url, pb_blacklist);
}
function isInList(url, list) {
if (list) {
return list.some(function (li) {
return new RegExp("https?://(www\.|.*\.)?" + li + "+").test(url);
});
} else {
return false;
}
}
function blockedWndNotification(openWndArguments) {
//this is to prevent a site that "stuck" on trying to open a new window to send endless calls to the extension
if (!lastBlockTime || lastBlockTime < Date.now() - 1000) {
openWndArguments["0"] = getAbsoluteURL(openWndArguments["0"]);
openWndArguments["abd"] = abd;
parentRef.postMessage({ type: "blockedWindow", args: JSON.stringify(openWndArguments) }, parentOrigin);
}
lastBlockTime = Date.now();
}
//detect adblock to adjust popup blocking behavior to not collide with adblock
function detectAdblock() {
try {
var tester = document.createElement('div');
tester.innerHTML = ' ';
tester.className = 'adsbox';
tester.style.cssText = "position:absolute;top-1000px;left:-1000px;";
document.body.appendChild(tester);
window.setTimeout(function () {
if (tester.offsetHeight === 0) {
abd = true;
}
tester.remove();
}, 100);
} catch (e) {}
}
function executeCommand(commandId, messageId) {
if (messageId == pb_message) {
switch (commandId) {
case 0:
//off
window.open = originalWindowOpenFn;
document.createElement = originalCreateElementFn;
document.createEvent = originalCreateEventFn;
HTMLElement.prototype.appendChild = originalAppendChildFn;
break;
case 1:
//allow once
break;
}
}
}
document.addEventListener("fullscreenchange", function () {
onFullScreen(document.fullscreen);
}, false);
document.addEventListener("mozfullscreenchange", function () {
onFullScreen(document.mozFullScreen);
}, false);
document.addEventListener("webkitfullscreenchange", function () {
onFullScreen(document.webkitIsFullScreen);
}, false);
//document.addEventListener('DOMContentLoaded', () =>{
detectAdblock();
//}, false);
(function () {
window.pbExternalCommand = function (commandId, messageId) {
executeCommand(commandId, messageId);
};
})();
};
inject();
})();
(function () {
var pb_blacklist = [];
var pb_whitelist = ["pan.baidu.com","youpin.mi.com","lwwf1.chatango.com","study.163.com","qq.com","tmall.com","iqiyi.com","jd.com","jiyoujia.com","engage.wixapps.net","li<x>nkedin.com","google","www.gmail.com","www.pinterest.com","www.youtube.com","www.facebook.com","search.yahoo.com","chrome://newtab","www.food.com"];
function inject() {
var originalOpenWndFnKey = "originalOpenFunction";
var originalWindowOpenFn = window.open;
var originalCreateElementFn = document.createElement;
var originalAppendChildFn = HTMLElement.prototype.appendChild;
var originalCreateEventFn = document.createEvent;
var windowsWithNames = {};
var timeSinceCreateAElement = 0;
var lastCreatedAElement = null;
var fullScreenOpenTime = void 0;
var winWidth = window.innerWidth;
var winHeight = window.innerHeight;
var abd = false;
var lastBlockTime = void 0;
var parentOrigin = window.location != window.parent.location ? document.referrer || window.parent.location || '*' : document.location;
var parentRef = window.parent;
//window[originalOpenWndFnKey] = window.open; // save the original open window as global param
function getAbsoluteURL(ba<x>seURL) {
if (/^about:blank/i.test(ba<x>seURL)) {
return ba<x>seURL;
}
if (/^(https?:)?\/\//.test(ba<x>seURL)) {
return ba<x>seURL;
}
ba<x>seURL = location.origin + (!/^\//.test(ba<x>seURL) ? '/' : '') + ba<x>seURL;
return ba<x>seURL;
}
function newWindowOpenFn() {
var openWndArguments = arguments;
var useOriginalOpenWnd = true;
var generatedWindow = null;
function getWindowName(openWndArguments) {
var windowName = openWndArguments[1];
if (windowName != null && !["_blank", "_parent", "_self", "_top"].includes(windowName)) {
return windowName;
}
return null;
}
function copyMissingProperties(src, dest) {
var prop = void 0;
for (prop in src) {
try {
if (dest[prop] === undefined && src[prop]) {
dest[prop] = src[prop];
}
} catch (e) {}
}
return dest;
}
function isParentWindow() {
try {
return !!(parent.Window && capturingElement instanceof parent.Window);
} catch (e) {
return false;
}
}
function isOverlayish(el) {
var style = el && el.style;
if (style && /fixed|absolute/.test(style.position) && el.offsetWidth >= winWidth * 0.6 && el.offsetHeight >= winHeight * 0.75) {
return true;
}
return false;
}
var capturingElement = null; // the element who registered to the event
var srcElement = null; // the clicked on element
var closestParentli<x>nk = null;
if (window.event != null) {
capturingElement = window.event.currentTarget;
srcElement = window.event.srcElement;
}
if (srcElement != null && srcElement instanceof HTMLElement) {
closestParentli<x>nk = srcElement.closest('a');
if (closestParentli<x>nk && closestParentli<x>nk.href) {
openWndArguments[3] = closestParentli<x>nk.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[sc<x>ript_params.fullScreenFnKey]) {
window.clearTimeout(window[sc<x>ript_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: ' + openWndArguments[0] + ' because a it was blured';
generatedWindow.close();
blockedWndNotification(openWndArguments);
} else {
originalWndBlurFn();
}
};
}
////////////////////////////////////////////////////////#B
blockedWndNotification({ "0": newElement.href });
return true;
}
}
return originalDispatchEventFn.call(this, event);
};
lastCreatedAElement = newElement;
}
return newElement;
};
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
// Block artificial mouse click on frashly created elements
/////////////////////////////////////////////////////////////////////////////////
document.createEvent = function () {
try {
if (arguments[0].toLowerCase().includes("mouse") && new Date().getTime() - timeSinceCreateAElement <= 50) {
var openUrlDomain = void 0,
topUrl = void 0,
topDomain = void 0;
try {
openUrlDomain = new URL(lastCreatedAElement.href).hostname;
} catch (e) {}
try {
topUrl = window.location != window.parent.location ? document.referrer : document.location.href;
} catch (e) {}
try {
topDomain = new URL(topUrl).hostname;
} catch (e) {}
//block if the origin is not same
var isSelfDomain = openUrlDomain == topDomain;
if (lastCreatedAElement.href.trim() && !isInWhitelist(lastCreatedAElement.href) && !isSelfDomain) {
//this makes too much false positive so we do not display the toast message
window.pbreason = 'Blocked because \'a\' element was recently created and ' + arguments[0] + ' event was created shortly after';
arguments[0] = lastCreatedAElement.href;
blockedWndNotification({ "0": lastCreatedAElement.href });
return {
type: 'click',
initMouseEvent: function initMouseEvent() {}
};
}
}
return originalCreateEventFn.apply(document, arguments);
} catch (err) {}
};
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
// Monitor full screen requests
/////////////////////////////////////////////////////////////////////////////////
function onFullScreen(isInFullScreenMode) {
if (isInFullScreenMode) {
fullScreenOpenTime = new Date().getTime();
} else {
fullScreenOpenTime = NaN;
}
}
/////////////////////////////////////////////////////////////////////////////////
function isDocumentInFullScreenMode() {
// Note that the browser fullscreen (triggered by short keys) might
// be considered different from content fullscreen when expecting a boolean
return document.fullScreenElement && document.fullScreenElement !== null || // alternative standard methods
document.mozFullscreenElement != null || document.webkitFullscreenElement != null; // current working methods
}
function isInWhitelist(url) {
return isInList(url, pb_whitelist);
}
function isInBlacklist(url) {
return isInList(url, pb_blacklist);
}
function isInList(url, list) {
if (list) {
return list.some(function (li) {
return new RegExp("https?://(www\.|.*\.)?" + li + "+").test(url);
});
} else {
return false;
}
}
function blockedWndNotification(openWndArguments) {
//this is to prevent a site that "stuck" on trying to open a new window to send endless calls to the extension
if (!lastBlockTime || lastBlockTime < Date.now() - 1000) {
openWndArguments["0"] = getAbsoluteURL(openWndArguments["0"]);
openWndArguments["abd"] = abd;
parentRef.postMessage({ type: "blockedWindow", args: JSON.stringify(openWndArguments) }, parentOrigin);
}
lastBlockTime = Date.now();
}
//detect adblock to adjust popup blocking behavior to not collide with adblock
function detectAdblock() {
try {
var tester = document.createElement('div');
tester.innerHTML = ' ';
tester.className = 'adsbox';
tester.style.cssText = "position:absolute;top-1000px;left:-1000px;";
document.body.appendChild(tester);
window.setTimeout(function () {
if (tester.offsetHeight === 0) {
abd = true;
}
tester.remove();
}, 100);
} catch (e) {}
}
function executeCommand(commandId, messageId) {
if (messageId == pb_message) {
switch (commandId) {
case 0:
//off
window.open = originalWindowOpenFn;
document.createElement = originalCreateElementFn;
document.createEvent = originalCreateEventFn;
HTMLElement.prototype.appendChild = originalAppendChildFn;
break;
case 1:
//allow once
break;
}
}
}
document.addEventListener("fullscreenchange", function () {
onFullScreen(document.fullscreen);
}, false);
document.addEventListener("mozfullscreenchange", function () {
onFullScreen(document.mozFullScreen);
}, false);
document.addEventListener("webkitfullscreenchange", function () {
onFullScreen(document.webkitIsFullScreen);
}, false);
//document.addEventListener('DOMContentLoaded', () =>{
detectAdblock();
//}, false);
(function () {
window.pbExternalCommand = function (commandId, messageId) {
executeCommand(commandId, messageId);
};
})();
};
inject();
})();(责任编辑:刘锻)