-
Notifications
You must be signed in to change notification settings - Fork 5
/
inject_actions.js
11 lines (11 loc) · 3.65 KB
/
inject_actions.js
1
2
3
4
5
6
7
8
9
10
11
var FLASH_CLSID="{d27cdb6e-ae6d-11cf-96b8-444553540000}",typeId="application/x-itst-activex",updating=!1;function executeScript(a){var b=document.createElement("script");b.innerHTML=a;a=document.head||document.body||document.documentElement||document;a.insertBefore(b,a.firstChild);a.removeChild(b)}
function checkParents(a){for(var b=a,c=0;b&&1==b.nodeType;){if("none"==getComputedStyle(b).display){var d=a.id+" at level "+c;scriptConfig.none2block?(b.style.display="block",b.style.height="0px",b.style.width="0px",log("Remove display:none for "+d)):log("Warning: Detected display:none for "+d)}b=b.parentNode;++c}}
function getLinkDest(a){if("string"!=typeof a)return a;a=a.trim();return/^https?:\/\/.*/.exec(a)?a:"/"==a[0]?"/"==a[1]?location.protocol+a:location.origin+a:location.href.replace(/\/[^\/]*$/,"/"+a)}var hostElement=null;
function enableobj(a){updating=!0;a.setAttribute("clsid",getClsid(a));a.removeAttribute("classid");checkParents(a);var b=a.cloneNode(!0);b.type=typeId;for(var c=b.getElementsByTagName("script"),d=0;d<c.length;++d)c[d].parentNode.removeChild(c[d]);(c=b.getAttribute("codebase"))&&""!=c&&b.setAttribute("codebase",getLinkDest(c));b.activex_process=!0;a.parentNode.insertBefore(b,a);a.parentNode.removeChild(a);a=b;a.id&&(b="",a.form&&scriptConfig.formid&&(c=a.form.name,b+="document.all."+c+"."+a.id,b+=
" = document.all."+a.id+";\n",log("Set form[obj.id]: form: "+c+", object: "+a.id)),a.id&&scriptConfig.documentid&&(b+="delete document."+a.id+";\n",b+="document."+a.id+"="+a.id+";\n"),b&&executeScript(b));log("Enabled object, id: "+a.id+" clsid: "+getClsid(a));updating=!1;return a}function getClsid(a){if(a.hasAttribute("clsid"))return a.getAttribute("clsid");var a=a.getAttribute("classid"),b=a.indexOf(":");if("clsid"==a.substring(0,b).toLowerCase())return a=a.substring(b+1),"{"+a+"}"}
function notify(a){connect();a.command="DetectControl";port.postMessage(a)}
function process(a){if(!a.activex_process)if(onBeforeLoading.caller==enableobj||onBeforeLoading.caller==process||onBeforeLoading.caller==checkParents)log("Nested onBeforeLoading "+a.id);else if(a.type==typeId){if(!config||!config.pageRule)return log("Deactive unexpected object "+a.outerHTML),!0;log("Found objects created by client scripts");notify({href:location.href,clsid:b,actived:!0,rule:config.pageRule.identifier});a.activex_process=!0}else if(!(""!=a.type&&"application/x-oleobject"!=a.type)&&
a.hasAttribute("classid")&&getClsid(a).toLowerCase()!=FLASH_CLSID)if(null==config)log("Pending object ",a.id),pendingObjects.push(a);else{a.activex_process=!0;connect();var b=getClsid(a),c=config.shouldEnable({href:location.href,clsid:b});c?(enableobj(a),notify({href:location.href,clsid:b,actived:!0,rule:c.identifier})):notify({href:location.href,clsid:b,actived:!1})}}
function replaceSubElements(a){var b=a.querySelectorAll("object[classid]");"OBJECT"==a.tagName&&a.hasAttribute("classid")&&b.push(a);for(a=0;a<b.length;++a)process(b[a])}function onBeforeLoading(a){var b=a.target;"OBJECT"==b.nodeName&&(log("BeforeLoading "+b.id),process(b)&&a.preventDefault())}function onError(a){var b;b="Error: "+a.message;b=b+" at "+a.filename;b=b+":"+a.lineno;log(b);return!1}
function setUserAgent(){if(config.pageRule){var a=getUserAgent(config.pageRule.userAgent);a&&""!=a&&(log("Set userAgent: "+config.pageRule.userAgent),executeScript("(function(agent) {delete navigator.userAgent;navigator.userAgent = agent;delete navigator.appVersion;navigator.appVersion = agent.substr(agent.indexOf('/') + 1);if (agent.indexOf('MSIE') >= 0) {delete navigator.appName;navigator.appName = \"Microsoft Internet Explorer\";}})(\""+a+'")'))}}
function onSubtreeModified(a){updating||a.nodeType!=a.TEXT_NODE&&replaceSubElements(a.srcElement)};