-
Notifications
You must be signed in to change notification settings - Fork 5
/
inject_start.js
7 lines (7 loc) · 2.72 KB
/
inject_start.js
1
2
3
4
5
6
7
var controlLogFName="__npactivex_log",controlLogEvent="__npactivex_log_event__",config=null,port=null,logs=[],scriptConfig={none2block:!1,formid:!1,documentid:!1};function onControlLog(a){log(a.data)}window.addEventListener(controlLogEvent,onControlLog,!1);function connect(){if(!port){port=chrome.extension.connect();for(var a=0;a<logs.length;++a)port.postMessage({command:"Log",message:logs[a]});port&&config&&(logs=void 0)}}
function log(a){a=(new Date).toLocaleTimeString()+" "+a;config&&config.logEnabled&&console.log(a);port&&port.postMessage({command:"Log",message:a});(!config||!port)&&logs.push(a)}log("PageURL: "+location.href);var pendingObjects=[];
function init(a){config=new ActiveXConfig(a);if(config.logEnabled)for(a=0;a<logs.length;++a)console.log(logs[a]);eval(config.extScript);executeScript(config.pageScript);setUserAgent();log("Page rule:"+JSON.stringify(config.pageRule));for(a=0;a<pendingObjects.length;++a)pendingObjects[a].activex_process=!1,process(pendingObjects[a]),cacheConfig();delete pendingObjects}function cacheConfig(){sessionStorage.activex_config_cache=JSON.stringify(config)}
function loadConfig(a){config?(config=new ActiveXConfig(a),sessionStorage.activex_config_cache&&cacheConfig()):init(a);config.pageRule&&cacheConfig()}function loadSessionConfig(){var a=sessionStorage.activex_config_cache;a&&(log("Loading config from session cache"),init(JSON.parse(a)))}loadSessionConfig();var notifyBar=null,pageDOMLoaded=!1,needNotifyBar=!1;
function showNotifyBar(){if(!notifyBar)if(pageDOMLoaded){notifyBar={};log("Create notification bar");var a=chrome.extension.getURL("notifybar.html");if("BODY"==document.body.tagName){var b=document.createElement("iframe");b.frameBorder=0;b.src=a;b.height="35px";b.width="100%";b.style.top="0px";b.style.left="0px";b.style.zIndex="2000";b.style.position="fixed";notifyBar.iframe=b;document.body.insertBefore(b,document.body.firstChild);a=document.createElement("div");a.style.height=b.height;a.style.zIndex=
"1999";a.style.borderWidth="0px";a.style.borderStyle="solid";a.style.borderBottomWidth="1px";document.body.insertBefore(a,document.body.firstChild);notifyBar.placeHolder=a}}else needNotifyBar=!0}function dismissNotifyBar(){notifyBar&¬ifyBar.iframe&&(notifyBar.iframe.parentNode.removeChild(notifyBar.iframe),notifyBar.placeHolder.parentNode.removeChild(notifyBar.placeHolder))}
chrome.extension.onRequest.addListener(function(a,b,c){self==top&&"NotifyUser"==a.command?(showNotifyBar(a),c({})):self==top&&"DismissNotificationPage"==a.command&&(dismissNotifyBar(),c({}))});chrome.extension.sendRequest({command:"Configuration",href:location.href,top:self==top},loadConfig);window.addEventListener("beforeload",onBeforeLoading,!0);document.addEventListener("DOMSubtreeModified",onSubtreeModified,!0);