Guest User

Untitled

a guest
Feb 20th, 2019
1,612
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 78.26 KB | None | 0 0
  1. (function(){
  2. var KasperskyLab = {SIGNATURE:"C18A6769-E1D0-3640-AB4A-FB985907B87C",CSP_NONCE:"CDEBD804BD1DD04DA0E7F1946043683D",PLUGINS_LIST:"",PREFIX:"https://gc.kis.v2.scr.kaspersky-labs.com/",INJECT_ID:"4FF909F6-8F4A-BA4B-8BE7-D7A6D6A1C289",WORK_IDENTIFIERS:"C18A6769-E1D0-3640,9ECC8311-C30E-9B49,2A92F7BD-AFC0-A14B,F44175E1-3890-8D49,239C42EA-F36A-3240,64607014-2E6F-9A47,151A5078-CA8E-D144"}; var KasperskyLab = (function (context) {
  3.     function GetClass(obj) {
  4.         if (typeof obj === "undefined")
  5.             return "undefined";
  6.         if (obj === null)
  7.             return "null";
  8.         return Object.prototype.toString.call(obj)
  9.             .match(/^\[object\s(.*)\]$/)[1];
  10.     }
  11.     var exports = {}, undef;
  12.     function ObjectToJson(object) {
  13.         if (object === null || object == Infinity || object == -Infinity || object === undef)
  14.             return "null";
  15.         var className = GetClass(object);
  16.         if (className == "Boolean") {
  17.             return "" + object;
  18.         } else if (className == "Number") {
  19.             return window.isNaN(object) ? "null" : "" + object;
  20.         } else if (className == "String") {
  21.             var escapedStr = "" + object;
  22.             return "\"" + escapedStr.replace(/\\/g, "\\\\").replace(/\"/g, "\\\"") + "\"";
  23.         }
  24.         if (typeof object == "object") {
  25.             if (!ObjectToJson.check) ObjectToJson.check = [];
  26.             for (var i=0, chkLen=ObjectToJson.check.length ; i<chkLen ; ++i) {
  27.                if (ObjectToJson.check[i] === object) {
  28.                    throw new TypeError();
  29.                }
  30.            }
  31.            ObjectToJson.check.push(object);
  32.            var str = '';
  33.            if (className == "Array" || className == "Array Iterator") {
  34.                for (var index = 0, length = object.length; index < length; ++index) {
  35.                    str += ObjectToJson(object[index]) + ',';
  36.                }
  37.                ObjectToJson.check.pop();
  38.                return "["+str.slice(0,-1)+"]";
  39.            } else {
  40.                for (var property in object) {
  41.                    if (object.hasOwnProperty(property)) {
  42.                        str += '"' + property + '":' + ObjectToJson(object[property]) + ',';
  43.                    }
  44.                }
  45.                ObjectToJson.check.pop();
  46.                return "{"+str.slice(0,-1)+"}";
  47.            }
  48.        }
  49.        return undef;
  50.    }
  51.    exports.stringify = function (source) {
  52.        return ObjectToJson(source);
  53.    };
  54.    var parser = {
  55.        source : null,
  56.        grammar : /^[\x20\t\n\r]*(?:([,:\[\]{}]|true|false|null)|(-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)|"((?:[^\r\n\t\\\"]|\\(?:["\\\/trnfb]|u[0-9a-fA-F]{4}))*)")/,
  57.        ThrowError : function() {
  58.            throw new SyntaxError('JSON syntax error');
  59.        },
  60.        NextToken : function(token) {
  61.            this.source = token.input.slice(token[0].length);
  62.            return this.grammar.exec(this.source);
  63.        },
  64.        ParseArray : function(){
  65.            var token = this.grammar.exec(this.source),
  66.                parseItem = token && token[1] != ']',
  67.                result = [];
  68.            for(;;token = this.NextToken(token)) {
  69.                if (!token)
  70.                    this.ThrowError();
  71.                if (parseItem) {
  72.                    result.push(this.ParseValue(token));
  73.                    token = this.grammar.exec(this.source);
  74.                } else {
  75.                    if (token[1]) {
  76.                        if (token[1] == ']') {
  77.                            break;
  78.                        } else if (token[1] != ',') {
  79.                            this.ThrowError();
  80.                        }
  81.                    } else {
  82.                        this.ThrowError();
  83.                    }
  84.                }
  85.                parseItem = !parseItem;
  86.            }
  87.            return result;
  88.        },
  89.        ParseObject : function(){
  90.            var propertyName, parseProperty = true, result = {};
  91.            for(var token = this.grammar.exec(this.source);;token = this.NextToken(token)) {
  92.                if (!token)
  93.                    this.ThrowError();
  94.                if (parseProperty) {
  95.                    if (token[1] && token[1] == '}') {
  96.                        break;
  97.                    } else if (token[1] || token[2] || !token[3]) {
  98.                        this.ThrowError();
  99.                    }
  100.                    propertyName = token[3];
  101.                    token = this.NextToken(token);
  102.                    if (!token || !token[1] || token[1] != ':')
  103.                        this.ThrowError();
  104.                    parseProperty = false;
  105.                } else {
  106.                    if (!propertyName)
  107.                        this.ThrowError();
  108.                    result[ propertyName ] = this.ParseValue(token);
  109.                    token = this.NextToken(this.grammar.exec(this.source));
  110.                    if (token[1]) {
  111.                        if (token[1] == '}') {
  112.                            break;
  113.                        } else if (token[1] != ',') {
  114.                            this.ThrowError();
  115.                        }
  116.                    } else {
  117.                        this.ThrowError();
  118.                    }
  119.                    propertyName = undef;
  120.                    parseProperty = true;
  121.                }
  122.            }
  123.            return result;
  124.        },
  125.        ParseValue : function(token){
  126.            if (token[1]) {
  127.                switch (token[1]){
  128.                    case '[' :
  129.                        this.source = this.source.slice(token[0].length);
  130.                        return this.ParseArray();
  131.                    case '{' :
  132.                        this.source = this.source.slice(token[0].length);
  133.                        return this.ParseObject();
  134.                    case 'true' :
  135.                        return true;
  136.                    case 'false' :
  137.                        return false;
  138.                    case 'null' :
  139.                        return null;
  140.                    default:
  141.                        this.ThrowError();
  142.                }
  143.            } else if (token[2]) {
  144.                return  +token[2];
  145.            }
  146.            return token[3].replace(/\\(?:u(.{4})|(["\\\/'bfnrt]))/g, function(substr, utfCode, esc){
  147.                if(utfCode)
  148.                {
  149.                    return String.fromCharCode(parseInt(utfCode, 16));
  150.                }
  151.                else
  152.                {
  153.                    switch(esc) {
  154.                        case 'b': return '\b';
  155.                        case 'f': return '\f';
  156.                        case 'n': return '\n';
  157.                        case 'r': return '\r';
  158.                        case 't': return '\t';
  159.                        default:
  160.                            return esc;
  161.                    }
  162.                }
  163.            });
  164.        },
  165.        Parse : function(str) {
  166.            if ('String' != GetClass(str))
  167.                throw new TypeError();
  168.            this.source = str;
  169.            var token = this.grammar.exec(this.source);
  170.            if (!token)
  171.                this.ThrowError();
  172.            return this.ParseValue(token);
  173.        }
  174.    };
  175.    exports.parse = function (source) {
  176.        return parser.Parse(source);
  177.    };
  178.    context['JSONStringify'] = exports.stringify;
  179.    context['JSONParse'] = exports.parse;
  180.    return context;
  181. }).call(this, KasperskyLab || {});
  182. var KasperskyLab = (function ( ns) {
  183.     ns.MaxRequestDelay = 2000;
  184.     ns.Log = function()
  185.     {};
  186.     ns.SessionLog = function()
  187.     {};
  188.     ns.GetDomainName = function()
  189.     {
  190.         return document.location.hostname;
  191.     }
  192.     var originalWindowOpen = window.open;
  193.     ns.WindowOpen = function(url)
  194.     {
  195.         if (typeof(originalWindowOpen) === "function")
  196.             originalWindowOpen.call(window, url);
  197.         else
  198.             originalWindowOpen(url);   
  199.     }
  200.     ns.EncodeURI = encodeURI;
  201.     ns.GetResourceSrc = function () {};
  202.     ns.AddEventListener = function(element, name, func)
  203.     {
  204.         if ("addEventListener" in element)
  205.             element.addEventListener(name,
  206.                 function(e)
  207.                 {
  208.                     try
  209.                     {
  210.                         func(e || window.event);
  211.                     }
  212.                     catch (e)
  213.                     {
  214.                         ns.SessionLog(e);
  215.                     }
  216.                 }, true);
  217.         else
  218.             element.attachEvent("on" + name,
  219.                 function(e)
  220.                 {
  221.                     try
  222.                     {
  223.                         func.call(element, e || window.event);
  224.                     }
  225.                     catch (e)
  226.                     {
  227.                         ns.SessionLog(e);
  228.                     }
  229.                 });
  230.     };
  231.     ns.AddRemovableEventListener = function ( element,  name,  func) {
  232.         if (element.addEventListener)
  233.             element.addEventListener(name, func, true);
  234.         else
  235.             element.attachEvent('on' + name, func);
  236.     };
  237.     ns.RunModule = function(func, timeout)
  238.     {
  239.         if (document.readyState === "loading")
  240.         {
  241.             if (timeout)
  242.                 ns.SetTimeout(func, timeout);
  243.             if (document.addEventListener)
  244.                 ns.AddEventListener(document, "DOMContentLoaded", func);
  245.             else
  246.                 ns.AddEventListener(document, "load", func);
  247.         }
  248.         else
  249.         {
  250.             func();
  251.         }
  252.     };
  253.     ns.RemoveEventListener = function ( element,  name, func) {
  254.         if (element.removeEventListener)
  255.             element.removeEventListener(name, func, true);
  256.         else
  257.             element.detachEvent('on' + name, func);
  258.     };
  259.     ns.SetTimeout = function(func, timeout)
  260.     {
  261.         return setTimeout(
  262.             function()
  263.             {
  264.                 try
  265.                 {
  266.                     func();
  267.                 }
  268.                 catch (e)
  269.                 {
  270.                     ns.SessionLog(e);
  271.                 }
  272.             }, timeout);
  273.     }
  274.     ns.SetInterval = function(func, interval)
  275.     {
  276.         return setInterval(
  277.             function()
  278.             {
  279.                 try
  280.                 {
  281.                     func();
  282.                 }
  283.                 catch (e)
  284.                 {
  285.                     ns.SessionLog(e);
  286.                 }
  287.             }, interval);
  288.     }
  289.     function InsertStyleRule( style,  rule) {
  290.         if (style.styleSheet)
  291.         {
  292.             style.styleSheet.cssText += rule + '\n';
  293.         }
  294.         else
  295.         {
  296.             style.appendChild(document.createTextNode(rule));
  297.             ns.SetTimeout(
  298.                 function()
  299.                 {
  300.                     if (!style.sheet)
  301.                         return;
  302.                     var rules = style.sheet.cssRules || style.sheet.rules;
  303.                     if (rules && rules.length === 0)
  304.                         style.sheet.insertRule(rule);
  305.                 }, 500);
  306.         }
  307.     }
  308.     ns.AddStyles = function (rules)
  309.     {
  310.         return ns.AddDocumentStyles(document, rules);
  311.     }
  312.     ns.AddDocumentStyles = function(document, rules)
  313.     {
  314.         if (typeof rules !== 'object' || rules.constructor !== Array) {
  315.             return;
  316.         }
  317.         var style = document.createElement('style');
  318.         style.type = 'text/css';
  319.         style.setAttribute('nonce', ns.ContentSecurityPolicyNonceAttribute);
  320.         for (var i = 0, len = rules.length; i < len; ++i)
  321.         {
  322.             var rule = rules[i];
  323.             if (document.querySelectorAll)
  324.             {
  325.                 InsertStyleRule(style, rule);
  326.             }
  327.             else
  328.             {
  329.                 var styleBegin = rule.lastIndexOf('{');
  330.                 if (styleBegin == -1)
  331.                     continue;
  332.                 var styleText = rule.substr(styleBegin);
  333.                 var selectors = rule.substr(0, styleBegin).split(',');
  334.                 if (style.styleSheet)
  335.                 {
  336.                     var cssText = '';
  337.                     for (var j = 0; j != selectors.length; ++j)
  338.                         cssText += selectors[j] + styleText + '\n';
  339.                     style.styleSheet.cssText += cssText;
  340.                 }
  341.                 else
  342.                 {
  343.                     for (var j = 0; j != selectors.length; ++j)
  344.                         style.appendChild(document.createTextNode(selectors[j] + styleText));
  345.                 }
  346.             }
  347.         }
  348.         if (document.head)
  349.             document.head.appendChild(style);
  350.         else
  351.             document.getElementsByTagName('head')[0].appendChild(style);
  352.         return style;
  353.     };
  354.     ns.AddCssLink = function(document, href, loadCallback, errorCallback)
  355.     {
  356.         var link = document.createElement("link");
  357.         link.type = "text/css";
  358.         link.rel = "stylesheet";
  359.         link.href = href;
  360.         if (loadCallback)
  361.         {
  362.             ns.AddEventListener(link, "load", function()
  363.                 {
  364.                     try
  365.                     {
  366.                         link && link.sheet && link.sheet.cssText;  
  367.                         loadCallback();
  368.                     }
  369.                     catch(e)
  370.                     {
  371.                         if (errorCallback)
  372.                             errorCallback();
  373.                     }
  374.                 });
  375.         }
  376.         if (errorCallback)
  377.         {
  378.             ns.AddEventListener(link, "error",
  379.                 function()
  380.                 {
  381.                     errorCallback();
  382.                     ns.SessionLog("failed load resource: " + href);
  383.                 });
  384.         }
  385.         if (document.head)
  386.             document.head.appendChild(link);
  387.         else
  388.             document.getElementsByTagName("head")[0].appendChild(link);
  389.     }
  390.     ns.GetCurrentTime = function () {
  391.         return new Date().getTime();
  392.     };
  393.     ns.GetPageScroll = function()
  394.     {
  395.         return {
  396.                 left: (document.documentElement && document.documentElement.scrollLeft) || document.body.scrollLeft,
  397.                 top: (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop
  398.             };
  399.     };
  400.     ns.GetPageHeight = function()
  401.     {
  402.         return document.documentElement.clientHeight || document.body.clientHeight;
  403.     };
  404.     ns.GetPageWidth = function()
  405.     {
  406.         return document.documentElement.clientWidth || document.body.clientWidth;
  407.     };
  408.     ns.IsDefined = function (variable)
  409.     {
  410.         return "undefined" !== typeof(variable);
  411.     };
  412.     ns.StopProcessingEvent = function(evt)
  413.     {
  414.         if (evt.preventDefault)
  415.             evt.preventDefault();
  416.         else
  417.             evt.returnValue = false;
  418.         if (evt.stopPropagation)
  419.             evt.stopPropagation();
  420.         if (ns.IsDefined(evt.cancelBubble))
  421.             evt.cancelBubble = true;
  422.     }
  423.     ns.AddIframeDoctype = function(element)
  424.     {
  425.         var frameDocument = element.contentDocument || element.contentWindow.document;
  426.         if (document.implementation && document.implementation.createDocumentType)
  427.         {
  428.             var newDoctype = document.implementation.createDocumentType('html', '', '');
  429.             if (frameDocument.childNodes.length)
  430.                 frameDocument.insertBefore(newDoctype, frameDocument.childNodes[0]);
  431.             else
  432.                 frameDocument.appendChild(newDoctype);
  433.         }
  434.         else
  435.         {
  436.             frameDocument.write("<!DOCTYPE html>");
  437.             frameDocument.close();
  438.         }
  439.     }
  440.     function IsGoogleSearch(linkElement)
  441.     {
  442.         var parentTagName = linkElement.parentNode.tagName.toLowerCase();
  443.         if (parentTagName === "div") {
  444.             if (linkElement.className)
  445.                 return false;
  446.         }
  447.         else if (parentTagName !== "h3") {
  448.             return false;
  449.         }
  450.         return linkElement.parentNode.className.toLowerCase() === "r";
  451.     }
  452.     function IsYandexSearch(linkElement)
  453.     {
  454.         if (linkElement.parentNode.tagName.toLowerCase() === "h2" && (
  455.                 linkElement.className.toLowerCase().indexOf("serp-item__title-link") !== -1 ||
  456.                 linkElement.className.toLowerCase().indexOf("b-serp-item__title-link") !== -1 ||
  457.                 linkElement.className.toLowerCase().indexOf("organic__url") !== -1))
  458.             return true;
  459.         else
  460.             return false;
  461.     }
  462.     function IsYahooSearch(linkElement)
  463.     {
  464.         if (linkElement.className.toLowerCase().indexOf("ac-1st") !== -1 ||
  465.             linkElement.className.toLowerCase().indexOf("ac-21th") !== -1)
  466.             return true;
  467.         return false;
  468.     }
  469.     function IsYahooLocalSearch(linkElement)
  470.     {
  471.         return linkElement.className.toLowerCase().indexOf("td-u") !== -1;
  472.     }
  473.     function IsYahooCoSearch(linkElement)
  474.     {
  475.         if (linkElement.parentNode.tagName.toLowerCase() === "h3" &&
  476.             linkElement.parentNode.parentNode &&
  477.             linkElement.parentNode.parentNode.className.toLowerCase() === "hd")
  478.             return true;
  479.         return false;
  480.     }
  481.     function IsBingSearch(linkElement)
  482.     {
  483.         if (linkElement.parentNode.tagName.toLowerCase() !== "h2" || !linkElement.parentNode.parentNode)
  484.             return false;
  485.         if (linkElement.parentNode.parentNode.className.toLowerCase().indexOf("sb_tlst") !== -1 ||
  486.             linkElement.parentNode.parentNode.className.toLowerCase().indexOf("b_algo") !== -1)
  487.             return true;
  488.         if (linkElement.parentNode.parentNode.parentNode &&
  489.             linkElement.parentNode.parentNode.className.toLowerCase().indexOf("b_title") !== -1 &&
  490.             linkElement.parentNode.parentNode.parentNode.className.toLowerCase().indexOf("b_algo") !== -1)
  491.             return true;
  492.         return false;
  493.     }
  494.     function IsMailRuSearch(linkElement)
  495.     {
  496.         if (linkElement.target.toLowerCase() === "_blank" && (
  497.             linkElement.parentNode.className.toLowerCase() === "res-head" ||
  498.             linkElement.parentNode.className.toLowerCase() === "result__title"))
  499.             return true;
  500.         return false;
  501.     }
  502.     function IsRamblerRuSearch(linkElement)
  503.     {
  504.         if (linkElement.className.toLowerCase() === "b-serp-item__link")
  505.             return true;
  506.         return false;
  507.     }
  508.     function IsBaiduComSearch(linkElement)
  509.     {
  510.         if (linkElement.parentNode.className.toLowerCase() === "t")
  511.             return true;
  512.         return false;
  513.     }
  514.     function IsBaiduJpSearch(linkElement)
  515.     {
  516.         if (linkElement.parentNode.tagName.toLowerCase() === "h3" &&
  517.             linkElement.parentNode.parentNode &&
  518.             linkElement.parentNode.parentNode.parentNode &&
  519.             linkElement.parentNode.parentNode.parentNode.className.toLowerCase() === "web")
  520.             return true;
  521.         return false;
  522.     }
  523.     function IsAskComSearch(linkElement)
  524.     {
  525.         if (linkElement.className.toLowerCase() === "partialsearchresults-item-title-link result-link")
  526.             return true;
  527.         return false;
  528.     }
  529.     function NotSearchSite()
  530.     {
  531.         return false;
  532.     }
  533.     function DecodeURI(query)
  534.     {
  535.         return decodeURIComponent(query.replace(/\+/g, ' '));
  536.     }
  537.     function GetSearchRequest(parameterName, decodeUriFunc)
  538.     {
  539.         var parameters = document.location.href.split(/[?#&]/);
  540.         var result = "";
  541.         for (var i = 0; i < parameters.length; ++i)
  542.         {
  543.             var parameter = parameters[i];
  544.             var parameterSeparatorPos = parameter.indexOf("=");
  545.             if (parameterSeparatorPos == -1)
  546.                 continue;
  547.             if (parameter.substr(0, parameterSeparatorPos) != parameterName)
  548.                 continue;
  549.             if (decodeUriFunc)
  550.                 result = decodeUriFunc(parameter.substr(parameterSeparatorPos + 1));
  551.             else
  552.                 result = DecodeURI(parameter.substr(parameterSeparatorPos + 1));
  553.         }
  554.         return result;
  555.     }
  556.     function NotSearchSiteRequest()
  557.     {
  558.         return "";
  559.     }
  560.     function GetGeneralSearchSiteRequest()
  561.     {
  562.         return GetSearchRequest('q');
  563.     }
  564.     function GetYahooSearchSiteRequest()
  565.     {
  566.         return GetSearchRequest('p');
  567.     }
  568.     function GetYandexSearchSiteRequest()
  569.     {
  570.         return GetSearchRequest('text');
  571.     }
  572.     function GetRamblerSearchSiteRequest()
  573.     {
  574.         return GetSearchRequest('query');
  575.     }
  576.     function GetBaiduSearchSiteRequest()
  577.     {
  578.         return GetSearchRequest('wd');
  579.     }
  580.     function GetGoogleTypedSearchRequest()
  581.     {
  582.         var t = document.getElementById('lst-ib');
  583.         if (t && t.tagName.toLowerCase() == "input")
  584.             return t.value;
  585.         else
  586.             return ns.GetSearchSiteRequest();
  587.     }
  588.     try
  589.     {
  590.         var currentPageUrl = document.location.href;
  591.         var schemeEndPos = currentPageUrl.indexOf("://");
  592.         var linkFilterFunction;
  593.         var getSearchSiteRequest;
  594.         var getTypedRequest = null;
  595.         if (schemeEndPos !== -1)
  596.         {
  597.             var host = currentPageUrl.substr(schemeEndPos + 3).toLowerCase();
  598.             if (host.indexOf("www.google.") === 0)
  599.             {
  600.                 linkFilterFunction = IsGoogleSearch;
  601.                 getSearchSiteRequest = GetGeneralSearchSiteRequest;
  602.                 getTypedRequest =  GetGoogleTypedSearchRequest;
  603.             }
  604.             else if (host.indexOf("yandex.") === 0 || host.indexOf("www.yandex.") === 0)
  605.             {
  606.                 linkFilterFunction = IsYandexSearch;
  607.                 getSearchSiteRequest = GetYandexSearchSiteRequest;
  608.             }
  609.             else if (host.indexOf("search.yahoo.com") === 0)
  610.             {
  611.                 linkFilterFunction = IsYahooSearch;
  612.                 getSearchSiteRequest = GetYahooSearchSiteRequest;
  613.             }
  614.             else if (host.indexOf("search.yahoo.co.") === 0)
  615.             {
  616.                 linkFilterFunction = IsYahooCoSearch;
  617.                 getSearchSiteRequest = GetYahooSearchSiteRequest;
  618.             }
  619.             else if (host.indexOf("search.yahoo.com") !== -1)
  620.             {
  621.                 linkFilterFunction = IsYahooLocalSearch;
  622.                 getSearchSiteRequest = GetYahooSearchSiteRequest;
  623.             }
  624.             else if (host.indexOf("www.bing.com") === 0)
  625.             {
  626.                 linkFilterFunction = IsBingSearch;
  627.                 getSearchSiteRequest = GetGeneralSearchSiteRequest;
  628.             }
  629.             else if (host.indexOf("go.mail.ru") === 0)
  630.             {
  631.                 linkFilterFunction = IsMailRuSearch;
  632.                 getSearchSiteRequest = GetGeneralSearchSiteRequest;
  633.             }
  634.             else if (host.indexOf("nova.rambler.ru") === 0)
  635.             {
  636.                 linkFilterFunction = IsRamblerRuSearch;
  637.                 getSearchSiteRequest = GetRamblerSearchSiteRequest;
  638.             }
  639.             else if (host.indexOf("www.baidu.com") === 0)
  640.             {
  641.                 linkFilterFunction = IsBaiduComSearch;
  642.                 getSearchSiteRequest = GetBaiduSearchSiteRequest;
  643.             }
  644.             else if (host.indexOf("www.baidu.jp") === 0)
  645.             {
  646.                 linkFilterFunction = IsBaiduJpSearch;
  647.                 getSearchSiteRequest = GetBaiduSearchSiteRequest;
  648.             }
  649.             else if (host.indexOf("www.ask.com") === 0)
  650.             {
  651.                 linkFilterFunction = IsAskComSearch;
  652.                 getSearchSiteRequest = GetGeneralSearchSiteRequest;
  653.             }
  654.             else
  655.             {
  656.                 linkFilterFunction = NotSearchSite;
  657.                 getSearchSiteRequest = NotSearchSiteRequest;
  658.             }          
  659.         }
  660.         ns.IsLinkSearchResult = linkFilterFunction;
  661.         ns.GetSearchSiteRequest = getSearchSiteRequest;
  662.         ns.GetTypedSearchRequest = getTypedRequest ? getTypedRequest : getSearchSiteRequest;
  663.     }
  664.     catch(e)
  665.     {
  666.         ns.IsLinkSearchResult = NotSearchSite;
  667.         ns.GetSearchSiteRequest = NotSearchSiteRequest;
  668.         ns.GetTypedSearchRequest = NotSearchSiteRequest;
  669.     }
  670.     function IsElementNode(node)
  671.     {
  672.         return node.nodeType === 1;
  673.     }
  674.     function IsNodeContainsElementWithTag(node, observeTag)
  675.     {
  676.         return observeTag == "*" || (IsElementNode(node) && (node.tagName.toLowerCase() === observeTag || node.getElementsByTagName(observeTag).length > 0));
  677.     }
  678.     function MutationChangeObserver(observeTag)
  679.     {
  680.         var m_observer;
  681.         var m_callback;
  682.         var m_functionCheckInteresting = observeTag ? function(node){return IsNodeContainsElementWithTag(node, observeTag);} : IsElementNode;
  683.         function ProcessNodeList(nodeList)
  684.         {
  685.             for (var i = 0; i < nodeList.length; ++i)
  686.             {
  687.                 if (m_functionCheckInteresting(nodeList[i]))
  688.                     return true;
  689.             }
  690.             return false;
  691.         }
  692.         function ProcessDomChange(records)
  693.         {
  694.             if (!m_callback)
  695.                 return;
  696.             for (var i = 0; i < records.length; ++i)
  697.             {
  698.                 var record = records[i];
  699.                 if ((record.addedNodes.length && ProcessNodeList(record.addedNodes)) ||
  700.                     (record.removedNodes.length && ProcessNodeList(record.removedNodes)))
  701.                 {
  702.                     m_callback();
  703.                     return;
  704.                 }
  705.             }
  706.         }
  707.         this.Start = function(callback)
  708.         {
  709.             m_callback = callback;
  710.             m_observer = new MutationObserver(ProcessDomChange);
  711.             m_observer.observe(document, { childList: true, subtree: true });
  712.         };
  713.         this.Stop = function()
  714.         {
  715.             m_observer.disconnect();
  716.             m_callback = null;
  717.         };
  718.     }
  719.     function DomEventsChangeObserver(observeTag)
  720.     {
  721.         var m_callback;
  722.         var m_functionCheckInteresting = observeTag ? function(node){return IsNodeContainsElementWithTag(node, observeTag);} : IsElementNode;
  723.         function ProcessEvent(event)
  724.         {
  725.             if (!m_callback)
  726.                 return;
  727.             if (m_functionCheckInteresting(event.target))
  728.                 m_callback();
  729.         }
  730.         this.Start = function(callback)
  731.         {
  732.             ns.AddRemovableEventListener(window, "DOMNodeInserted", ProcessEvent);
  733.             ns.AddRemovableEventListener(window, "DOMNodeRemoved", ProcessEvent);
  734.             m_callback = callback;
  735.         }
  736.         this.Stop = function()
  737.         {
  738.             ns.RemoveEventListener(window, "DOMNodeInserted", ProcessEvent);
  739.             ns.RemoveEventListener(window, "DOMNodeRemoved", ProcessEvent);
  740.             m_callback = null;
  741.         }
  742.     }
  743.     function TimeoutChangeObserver(observeTag)
  744.     {
  745.         var m_interval;
  746.         var m_callback;
  747.         var m_tagCount;
  748.         var m_attribute = 'klot_' + ns.GetCurrentTime();
  749.         function IsChangesOccure(nodeList)
  750.         {
  751.             for (var i = 0; i < nodeList.length; ++i)
  752.                 if (!nodeList[i][m_attribute])
  753.                     return true;
  754.             return false;
  755.         }
  756.         function FillTagInfo(nodeList)
  757.         {
  758.             m_tagCount = nodeList.length;
  759.             for (var i = 0; i < m_tagCount; ++i)
  760.                 nodeList[i][m_attribute] = true;
  761.         }
  762.         function TimeoutProcess()
  763.         {
  764.             if (!m_callback)
  765.                 return;
  766.             var nodeList = observeTag ? document.getElementsByTagName(observeTag) : document.getElementsByTagName("*");
  767.             if (nodeList.length !== m_tagCount || IsChangesOccure(nodeList))
  768.             {
  769.                 FillTagInfo(nodeList);
  770.                 m_callback();
  771.             }
  772.         }
  773.         this.Start = function(callback)
  774.         {
  775.             m_callback = callback;
  776.             FillTagInfo(document.getElementsByTagName(observeTag));
  777.             m_interval = ns.SetInterval(TimeoutProcess, 10 * 1000);
  778.             if (document.readyState !== "complete")
  779.                 ns.AddEventListener(window, "load", TimeoutProcess);
  780.         }
  781.         this.Stop = function()
  782.         {
  783.             clearInterval(m_interval);
  784.             m_callback = null;
  785.         }
  786.     }
  787.     ns.GetDomChangeObserver = function(observeTag)
  788.     {
  789.         var observeTagLowerCase = observeTag ? observeTag.toLowerCase() : observeTag;
  790.         if (window.MutationObserver && document.documentMode !== 11)   
  791.             return new MutationChangeObserver(observeTagLowerCase);
  792.         if (window.addEventListener)
  793.             return new DomEventsChangeObserver(observeTagLowerCase);
  794.         return new TimeoutChangeObserver(observeTagLowerCase);
  795.     }
  796.     ns.StartLocationHref = document.location.href;
  797.     return ns;
  798. }) (KasperskyLab || {});
  799. (function (ns) {
  800.     function md5cycle(x, k) {
  801.         var a = x[0],
  802.         b = x[1],
  803.         c = x[2],
  804.         d = x[3];
  805.         a = ff(a, b, c, d, k[0], 7, -680876936);
  806.         d = ff(d, a, b, c, k[1], 12, -389564586);
  807.         c = ff(c, d, a, b, k[2], 17, 606105819);
  808.         b = ff(b, c, d, a, k[3], 22, -1044525330);
  809.         a = ff(a, b, c, d, k[4], 7, -176418897);
  810.         d = ff(d, a, b, c, k[5], 12, 1200080426);
  811.         c = ff(c, d, a, b, k[6], 17, -1473231341);
  812.         b = ff(b, c, d, a, k[7], 22, -45705983);
  813.         a = ff(a, b, c, d, k[8], 7, 1770035416);
  814.         d = ff(d, a, b, c, k[9], 12, -1958414417);
  815.         c = ff(c, d, a, b, k[10], 17, -42063);
  816.         b = ff(b, c, d, a, k[11], 22, -1990404162);
  817.         a = ff(a, b, c, d, k[12], 7, 1804603682);
  818.         d = ff(d, a, b, c, k[13], 12, -40341101);
  819.         c = ff(c, d, a, b, k[14], 17, -1502002290);
  820.         b = ff(b, c, d, a, k[15], 22, 1236535329);
  821.         a = gg(a, b, c, d, k[1], 5, -165796510);
  822.         d = gg(d, a, b, c, k[6], 9, -1069501632);
  823.         c = gg(c, d, a, b, k[11], 14, 643717713);
  824.         b = gg(b, c, d, a, k[0], 20, -373897302);
  825.         a = gg(a, b, c, d, k[5], 5, -701558691);
  826.         d = gg(d, a, b, c, k[10], 9, 38016083);
  827.         c = gg(c, d, a, b, k[15], 14, -660478335);
  828.         b = gg(b, c, d, a, k[4], 20, -405537848);
  829.         a = gg(a, b, c, d, k[9], 5, 568446438);
  830.         d = gg(d, a, b, c, k[14], 9, -1019803690);
  831.         c = gg(c, d, a, b, k[3], 14, -187363961);
  832.         b = gg(b, c, d, a, k[8], 20, 1163531501);
  833.         a = gg(a, b, c, d, k[13], 5, -1444681467);
  834.         d = gg(d, a, b, c, k[2], 9, -51403784);
  835.         c = gg(c, d, a, b, k[7], 14, 1735328473);
  836.         b = gg(b, c, d, a, k[12], 20, -1926607734);
  837.         a = hh(a, b, c, d, k[5], 4, -378558);
  838.         d = hh(d, a, b, c, k[8], 11, -2022574463);
  839.         c = hh(c, d, a, b, k[11], 16, 1839030562);
  840.         b = hh(b, c, d, a, k[14], 23, -35309556);
  841.         a = hh(a, b, c, d, k[1], 4, -1530992060);
  842.         d = hh(d, a, b, c, k[4], 11, 1272893353);
  843.         c = hh(c, d, a, b, k[7], 16, -155497632);
  844.         b = hh(b, c, d, a, k[10], 23, -1094730640);
  845.         a = hh(a, b, c, d, k[13], 4, 681279174);
  846.         d = hh(d, a, b, c, k[0], 11, -358537222);
  847.         c = hh(c, d, a, b, k[3], 16, -722521979);
  848.         b = hh(b, c, d, a, k[6], 23, 76029189);
  849.         a = hh(a, b, c, d, k[9], 4, -640364487);
  850.         d = hh(d, a, b, c, k[12], 11, -421815835);
  851.         c = hh(c, d, a, b, k[15], 16, 530742520);
  852.         b = hh(b, c, d, a, k[2], 23, -995338651);
  853.         a = ii(a, b, c, d, k[0], 6, -198630844);
  854.         d = ii(d, a, b, c, k[7], 10, 1126891415);
  855.         c = ii(c, d, a, b, k[14], 15, -1416354905);
  856.         b = ii(b, c, d, a, k[5], 21, -57434055);
  857.         a = ii(a, b, c, d, k[12], 6, 1700485571);
  858.         d = ii(d, a, b, c, k[3], 10, -1894986606);
  859.         c = ii(c, d, a, b, k[10], 15, -1051523);
  860.         b = ii(b, c, d, a, k[1], 21, -2054922799);
  861.         a = ii(a, b, c, d, k[8], 6, 1873313359);
  862.         d = ii(d, a, b, c, k[15], 10, -30611744);
  863.         c = ii(c, d, a, b, k[6], 15, -1560198380);
  864.         b = ii(b, c, d, a, k[13], 21, 1309151649);
  865.         a = ii(a, b, c, d, k[4], 6, -145523070);
  866.         d = ii(d, a, b, c, k[11], 10, -1120210379);
  867.         c = ii(c, d, a, b, k[2], 15, 718787259);
  868.         b = ii(b, c, d, a, k[9], 21, -343485551);
  869.         x[0] = add32(a, x[0]);
  870.         x[1] = add32(b, x[1]);
  871.         x[2] = add32(c, x[2]);
  872.         x[3] = add32(d, x[3]);
  873.     }
  874.     function cmn(q, a, b, x, s, t) {
  875.         a = add32(add32(a, q), add32(x, t));
  876.         return add32((a << s) | (a >>> (32 - s)), b);
  877.     }
  878.     function ff(a, b, c, d, x, s, t) {
  879.         return cmn((b & c) | ((~b) & d), a, b, x, s, t);
  880.     }
  881.     function gg(a, b, c, d, x, s, t) {
  882.         return cmn((b & d) | (c & (~d)), a, b, x, s, t);
  883.     }
  884.     function hh(a, b, c, d, x, s, t) {
  885.         return cmn(b^c^d, a, b, x, s, t);
  886.     }
  887.     function ii(a, b, c, d, x, s, t) {
  888.         return cmn(c^(b | (~d)), a, b, x, s, t);
  889.     }
  890.     function md51(s) {
  891.         var n = s.length,
  892.         state = [1732584193, -271733879, -1732584194, 271733878],
  893.         i;
  894.         for (i = 64; i <= s.length; i += 64) {
  895.             md5cycle(state, md5blk(s.substring(i - 64, i)));
  896.         }
  897.         s = s.substring(i - 64);
  898.         var tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
  899.         for (i = 0; i < s.length; i++)
  900.             tail[i >> 2] |= s.charCodeAt(i) << ((i % 4) << 3);
  901.         tail[i >> 2] |= 0x80 << ((i % 4) << 3);
  902.         if (i > 55) {
  903.             md5cycle(state, tail);
  904.             for (i = 0; i < 16; i++)
  905.                 tail[i] = 0;
  906.         }
  907.         tail[14] = n * 8;
  908.         md5cycle(state, tail);
  909.         return state;
  910.     }
  911.     function md5blk(s) {
  912.         var md5blks = [],
  913.         i;
  914.         for (i = 0; i < 64; i += 4) {
  915.             md5blks[i >> 2] = s.charCodeAt(i) +
  916.                  (s.charCodeAt(i + 1) << 8) +
  917.                  (s.charCodeAt(i + 2) << 16) +
  918.                  (s.charCodeAt(i + 3) << 24);
  919.         }
  920.         return md5blks;
  921.     }
  922.     var hex_chr = '0123456789abcdef'.split('');
  923.     function rhex(n) {
  924.         var s = '',
  925.         j = 0;
  926.         for (; j < 4; j++)
  927.             s += hex_chr[(n >> (j * 8 + 4)) & 0x0F]+hex_chr[(n >> (j * 8)) & 0x0F];
  928.         return s;
  929.     }
  930.     function hex(x) {
  931.         for (var i = 0; i < x.length; i++)
  932.             x[i] = rhex(x[i]);
  933.         return x.join('');
  934.     }
  935.     ns.md5 = function (s) {
  936.         return hex(md51(s));
  937.     };
  938.     function add32(a, b) {
  939.         return (a + b) & 0xFFFFFFFF;
  940.     }
  941.     if (ns.md5('hello') != '5d41402abc4b2a76b9719d911017c592') {
  942.         add32 = function(x, y) {
  943.             var lsw = (x & 0xFFFF) + (y & 0xFFFF),
  944.             msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  945.             return (msw << 16) | (lsw & 0xFFFF);
  946.         }
  947.     }
  948. })(KasperskyLab || {});
  949. var KasperskyLab = (function (ns)
  950. {
  951. ns.Balloon2 = function(pluginName, balloonSrc, balloonCssPostfix, session, getCoordCallback, onCloseHandler, locales, onDataReceiveHandler)
  952. {
  953.     var m_balloon = document.createElement("iframe");
  954.     var m_balloonId = pluginName + "_b";
  955.     var m_balloonSize = null;
  956.     var m_sizeCache = {};
  957.     var m_initStyleDataPair = {};
  958.     var m_isInitSent = false;
  959.     var m_updateTimeout;
  960.     var m_firstCreate = true;
  961.     var m_deactivatePlugin = function(){};
  962.     function InitializeBalloon()
  963.     {
  964.         m_balloon.scrolling = "no";
  965.         m_balloon.frameBorder = "0";
  966.         m_balloon.style.border = "0";
  967.         m_balloon.style.height = "1px";
  968.         m_balloon.style.width = "1px";
  969.         m_balloon.style.left = "1px";
  970.         m_balloon.style.top = "1px";
  971.         m_balloon.allowTransparency = "true";
  972.         m_balloon.style.zIndex = "2147483647";
  973.         m_balloon.style.position = "absolute";
  974.         document.body.appendChild(m_balloon);
  975.         HideBalloon();
  976.     }
  977.     function OnPing()
  978.     {
  979.         return IsDisplayed() ? 100 : ns.MaxRequestDelay;
  980.     }
  981.     function SendToFrame(args)
  982.     {
  983.         m_balloon.contentWindow.postMessage(ns.JSONStringify(args), "*");
  984.     }
  985.     function OnSizeMessage(sizeMessage)
  986.     {
  987.         var size = {
  988.             height: sizeMessage.height,
  989.             width: sizeMessage.width
  990.         };
  991.         PutSizeInCache(sizeMessage.style, size);
  992.         SetupBalloon(size);
  993.     }
  994.     function OnCloseMessage(closeData)
  995.     {
  996.         HideBalloon();
  997.         if (onCloseHandler && closeData.closeAction)
  998.             onCloseHandler(closeData.closeAction);
  999.     }
  1000.     function OnDataMessage(data)
  1001.     {
  1002.         if (onDataReceiveHandler)
  1003.             onDataReceiveHandler(data);
  1004.     }
  1005.     function ChangeSchemeIfNeed(url)
  1006.     {
  1007.         if (document.location.protocol === "https:")
  1008.             return url.replace("http:", "https:");
  1009.         return url;
  1010.     }
  1011.     function CreateBalloon(style, data, size)
  1012.     {
  1013.         if (m_firstCreate)
  1014.         {
  1015.             InitializeBalloon();
  1016.             m_firstCreate = false;
  1017.         }
  1018.         DisplayBalloon();
  1019.         if (m_balloon.src)
  1020.         {
  1021.             UpdateBalloon(style, data);
  1022.             return;
  1023.         }
  1024.         m_initStyleDataPair = {style: style, data: data};
  1025.         var fullSrc;
  1026.         if (typeof(balloonSrc) == "object")
  1027.             fullSrc = balloonSrc.src;
  1028.         else
  1029.             fullSrc = ns.GetResourceSrc(balloonSrc);
  1030.         m_balloon.src = fullSrc + "?cssSrc=" + encodeURIComponent(ChangeSchemeIfNeed(ns["GetResourceSrc"](balloonCssPostfix)));
  1031.         var balloonSize = size ? size : GetSizeFromCache(style);
  1032.         var dataToFrame = {
  1033.             command: "init",
  1034.             pluginName: m_balloonId,
  1035.             commandUrl: ChangeSchemeIfNeed(ns.GetCommandSrc()),
  1036.             isRtl: ns.IsRtl,
  1037.             needSize: !balloonSize,
  1038.             style: style
  1039.         };
  1040.         if (data)
  1041.             dataToFrame.data = data;
  1042.         if (size)
  1043.             dataToFrame.explicitSize = size;
  1044.         if (locales)
  1045.             dataToFrame.locales = locales;
  1046.         ns.AddEventListener(m_balloon, "load", function(){SendInit(dataToFrame);});
  1047.         if (balloonSize)
  1048.         {
  1049.             clearTimeout(m_updateTimeout);
  1050.             m_updateTimeout = ns.SetTimeout(function(){SetupBalloon(balloonSize);}, 0);
  1051.         }
  1052.     }
  1053.     function SendInit(dataToFrame)
  1054.     {
  1055.         dataToFrame.style = m_initStyleDataPair.style;
  1056.         dataToFrame.data = m_initStyleDataPair.data;
  1057.         m_isInitSent = true;
  1058.         SendToFrame(dataToFrame);
  1059.         session.ForceReceive();
  1060.     }
  1061.     function DisplayBalloon()
  1062.     {
  1063.         m_balloon.style.display = "";
  1064.         session.ForceReceive();
  1065.     }
  1066.     function IsDisplayed()
  1067.     {
  1068.         return !m_firstCreate && m_balloon.style.display === "";
  1069.     }
  1070.     function HideBalloon()
  1071.     {
  1072.         m_balloon.style.display = "none";
  1073.     }
  1074.     function DestroyBalloon()
  1075.     {
  1076.         m_deactivatePlugin(m_balloonId);
  1077.         m_balloon.blur();
  1078.         document.body.removeChild(m_balloon);
  1079.         m_balloon = null;
  1080.         m_balloonSize = null;
  1081.     }
  1082.     function PositionBalloon()
  1083.     {
  1084.         if (!m_balloonSize)
  1085.             return;
  1086.         var coords = getCoordCallback(m_balloonSize);
  1087.         m_balloon.style.height = m_balloonSize.height + "px";
  1088.         m_balloon.style.width = m_balloonSize.width + "px";
  1089.         m_balloon.style.left = Math.round(coords.x).toString() + "px";
  1090.         m_balloon.style.top = Math.round(coords.y).toString() + "px";
  1091.     }
  1092.     function SetupBalloon(balloonSize)
  1093.     {
  1094.         m_balloonSize = balloonSize;
  1095.         PositionBalloon();
  1096.     }
  1097.     function UpdateBalloon(style, data)
  1098.     {
  1099.         if (!m_isInitSent)
  1100.             m_initStyleDataPair = {style: style, data: data};
  1101.         var sizeFromCache = GetSizeFromCache(style);
  1102.         clearTimeout(m_updateTimeout);
  1103.         if (sizeFromCache)
  1104.         {
  1105.             m_updateTimeout = ns.SetTimeout(function(){SetupBalloon(sizeFromCache);}, 0);
  1106.         }
  1107.         else
  1108.         {
  1109.             m_balloon.style.height = "1px";
  1110.             m_balloon.style.width = "1px";
  1111.             m_balloonSize = {height: 1, width: 1};
  1112.         }
  1113.         var dataToFrame = {
  1114.             command: "update",
  1115.             style: style,
  1116.             data: data,
  1117.             needSize: !sizeFromCache
  1118.         };
  1119.         SendToFrame(dataToFrame);
  1120.     }
  1121.     function GetSizeFromCache(style)
  1122.     {
  1123.         return m_sizeCache[style ? style.toString() : ""];
  1124.     }
  1125.     function PutSizeInCache(style, size)
  1126.     {
  1127.         m_sizeCache[style ? style.toString() : ""] = size;
  1128.     }
  1129.     this.Show = function(style, data)
  1130.     {
  1131.         CreateBalloon(style, data);
  1132.     }
  1133.     this.ShowWithSize = function(style, data, size)
  1134.     {
  1135.         CreateBalloon(style, data, size);
  1136.     }
  1137.     this.Resize = function(size)
  1138.     {
  1139.         SetupBalloon(size);
  1140.     }
  1141.     this.Hide = function()
  1142.     {
  1143.         HideBalloon();
  1144.     }
  1145.     this.Update = function(style, data)
  1146.     {
  1147.         UpdateBalloon(style, data);
  1148.     }
  1149.     this.UpdatePosition = function()
  1150.     {
  1151.         PositionBalloon();
  1152.     }
  1153.     this.Destroy = function()
  1154.     {
  1155.         DestroyBalloon();
  1156.     }
  1157.     session.InitializePlugin(
  1158.             function (activatePlugin, registerMethod, callFunction, deactivatePlugin) {
  1159.                 activatePlugin(m_balloonId, OnPing);
  1160.                 m_deactivatePlugin = deactivatePlugin;
  1161.                 registerMethod(
  1162.                     m_balloonId + ".message",
  1163.                     function (args)
  1164.                     {
  1165.                         if (args.length !== 1)
  1166.                         {
  1167.                             ns.SessionLog(m_balloonId + " wrong args. Args size: " + args.length);
  1168.                             return;
  1169.                         }
  1170.                         var message = ns.JSONParse(args[0]);
  1171.                         if (message.type === "size")
  1172.                             OnSizeMessage(message.data);
  1173.                         else if (message.type === "close")
  1174.                             OnCloseMessage(message.data);
  1175.                         else if (message.type === "data")
  1176.                             OnDataMessage(message.data);
  1177.                         else
  1178.                             ns.SessionLog("Unknown message type: " + message.type);
  1179.                     });
  1180.             });
  1181. };
  1182. return ns;
  1183. }) (KasperskyLab || {});
  1184. var KasperskyLab = (function (ns)
  1185. {
  1186. ns.AjaxTransportSupported = true;
  1187. var ajaxRequestProvider = (function ()
  1188.     {
  1189.         var oldOpen = window.XMLHttpRequest && window.XMLHttpRequest.prototype.open;
  1190.         var oldSend = window.XMLHttpRequest && window.XMLHttpRequest.prototype.send;
  1191.         var oldXHR = window.XMLHttpRequest;
  1192.         var oldXDR = window.XDomainRequest;
  1193.         return {
  1194.             GetAsyncRequest: function ()
  1195.                 {
  1196.                     var xmlhttp = oldXDR ? new oldXDR() : new oldXHR();
  1197.                     if (!oldXDR) {
  1198.                         xmlhttp.open = oldOpen;
  1199.                         xmlhttp.send = oldSend;
  1200.                     }
  1201.                     xmlhttp.onprogress = function(){};
  1202.                     return xmlhttp;
  1203.                 },
  1204.             GetSyncRequest: function ()
  1205.                 {
  1206.                     var xmlhttp = new oldXHR();
  1207.                     xmlhttp.open = oldOpen;
  1208.                     xmlhttp.send = oldSend;
  1209.                     xmlhttp.onprogress = function(){};
  1210.                     return xmlhttp;
  1211.                 }
  1212.         };
  1213.     })();
  1214. var restoreSessionCallback = function(){};
  1215. var PingPongCallReceiver = function(caller)
  1216. {
  1217.     var m_caller = caller;
  1218.     var m_isProductConnected = false;
  1219.     var m_pingWaitResponse = false;
  1220.     var m_requestDelay = ns.MaxRequestDelay;
  1221.     var m_requestTimer = null;
  1222.     var m_callCallback = function(){};
  1223.     var m_errorCallback = function(){};
  1224.     var m_updateCallback = function(){};
  1225.     function SendRequest()
  1226.     {
  1227.         try
  1228.         {
  1229.             m_caller.Call(
  1230.                 "from",
  1231.                 null,
  1232.                 null,
  1233.                  true,
  1234.                 function(result, parameters, method)
  1235.                 {
  1236.                     m_pingWaitResponse = false;
  1237.                     m_isProductConnected = true;
  1238.                     if (parameters === "undefined" || method === "undefined")
  1239.                     {
  1240.                         m_errorCallback('AJAX pong is not received. Product is deactivated');
  1241.                         return;
  1242.                     }
  1243.                     if (method)
  1244.                     {
  1245.                         ns.SetTimeout(function () { SendRequest(); }, 0);
  1246.                         m_callCallback(method, parameters);
  1247.                     }
  1248.                 },
  1249.                 function(error)
  1250.                 {
  1251.                     m_pingWaitResponse = false;
  1252.                     m_isProductConnected = false;
  1253.                     restoreSessionCallback();
  1254.                     m_errorCallback(error);
  1255.                 });
  1256.             m_pingWaitResponse = true;
  1257.         }
  1258.         catch (e)
  1259.         {
  1260.             m_errorCallback('Ajax send ping exception: ' + (e.message || e));
  1261.         }
  1262.     }
  1263.     function Ping()
  1264.     {
  1265.         try
  1266.         {
  1267.             if (m_pingWaitResponse)
  1268.             {
  1269.                 m_requestTimer = ns.SetTimeout(Ping, 100);
  1270.                 return;
  1271.             }
  1272.             m_requestDelay = m_updateCallback();
  1273.             SendRequest();
  1274.             m_requestTimer = ns.SetTimeout(Ping, m_requestDelay);
  1275.         }
  1276.         catch (e)
  1277.         {
  1278.             m_errorCallback('Send ping request: ' + (e.message || e));
  1279.         }
  1280.     }
  1281.     this.StartReceive = function(callCallback, errorCallback, updateCallback)
  1282.     {
  1283.         m_callCallback = callCallback;
  1284.         m_errorCallback = errorCallback;
  1285.         m_updateCallback = updateCallback;
  1286.         m_requestDelay = m_updateCallback();
  1287.         m_requestTimer = ns.SetTimeout(Ping, m_requestDelay);
  1288.     };
  1289.     this.ForceReceive = function()
  1290.     {
  1291.         clearTimeout(m_requestTimer);
  1292.         m_requestTimer = ns.SetTimeout(Ping, 0);
  1293.     }
  1294.     this.StopReceive = function()
  1295.     {
  1296.         clearTimeout(m_requestTimer);
  1297.         m_requestTimer = null;
  1298.         m_callCallback = function(){};
  1299.         m_errorCallback = function(){};
  1300.         m_updateCallback = function(){};
  1301.     };
  1302.     this.IsStarted = function()
  1303.     {
  1304.         return m_requestTimer !== null;
  1305.     }
  1306.     this.IsProductConnected = function()
  1307.     {
  1308.         return m_isProductConnected;
  1309.     };
  1310. };
  1311. var LongPoolingReceiver = function(caller)
  1312. {
  1313.     var m_caller = caller;
  1314.     var m_isProductConnected = false;
  1315.     var m_isStarted = false;
  1316.     var m_callCallback = function(){};
  1317.     var m_errorCallback = function(){};
  1318.     function SendRequest()
  1319.     {
  1320.         try
  1321.         {
  1322.             m_isProductConnected = true;
  1323.             m_caller.Call(
  1324.                 "longpooling",
  1325.                 null,
  1326.                 null,
  1327.                  true,
  1328.                 OnResponse,
  1329.                 function(error)
  1330.                 {
  1331.                     m_isProductConnected = false;
  1332.                     restoreSessionCallback();
  1333.                     m_errorCallback(error);
  1334.                 },
  1335.                 true);
  1336.         }
  1337.         catch (e)
  1338.         {
  1339.             ns.SessionLog(e);
  1340.             m_errorCallback("Ajax send ping exception: " + (e.message || e));
  1341.         }
  1342.     }
  1343.     function OnResponse(result, parameters, method)
  1344.     {
  1345.         if (!ns.IsDefined(parameters) || !ns.IsDefined(method))
  1346.         {
  1347.             m_errorCallback('AJAX pong is not received. Product is deactivated');
  1348.             return;
  1349.         }
  1350.         ns.SetTimeout(function () { SendRequest(); }, 0);
  1351.         if (method)
  1352.             m_callCallback(method, parameters);
  1353.     }
  1354.     this.StartReceive = function(callCallback, errorCallback)
  1355.     {
  1356.         m_isStarted = true;
  1357.         m_callCallback = callCallback;
  1358.         m_errorCallback = errorCallback;
  1359.         SendRequest();
  1360.     };
  1361.     this.ForceReceive = function(){}
  1362.     this.StopReceive = function()
  1363.     {
  1364.         m_isStarted = false;
  1365.         m_callCallback = function(){};
  1366.         m_errorCallback = function(){};
  1367.     };
  1368.     this.IsStarted = function()
  1369.     {
  1370.         return m_isStarted;
  1371.     }
  1372.     this.IsProductConnected = function()
  1373.     {
  1374.         return m_isProductConnected;
  1375.     };
  1376. };
  1377. ns.AjaxCaller = function()
  1378. {
  1379.     var m_path = ns.PREFIX + ns.SIGNATURE;
  1380.     var m_longPooling;
  1381.     var m_longPoolingRequest;
  1382.     function NoCacheParameter()
  1383.     {
  1384.         return "&nocache=" + Math.floor((1 + Math.random()) * 0x10000).toString(16);
  1385.     }
  1386.     function GetSpecialPlugins(predefined)
  1387.     {
  1388.         return (predefined) ? "&plugins=" + encodeURIComponent(predefined) : "";
  1389.     }
  1390.     function PrepareRequestObject(command, commandAttribute, isPost, isAsync)
  1391.     {
  1392.         var request = isAsync ? ajaxRequestProvider.GetAsyncRequest() : ajaxRequestProvider.GetSyncRequest();
  1393.         if (request)
  1394.         {
  1395.             var urlPath = m_path + "/" + command;
  1396.             if (commandAttribute)
  1397.                 urlPath += "/" + commandAttribute;
  1398.             if (isPost)
  1399.             {
  1400.                 request.open("POST", urlPath);
  1401.             }
  1402.             else
  1403.             {
  1404.                 if (urlPath.indexOf("?") === -1)
  1405.                     urlPath += "?get";
  1406.                 urlPath += NoCacheParameter();
  1407.                 request.open("GET", urlPath, isAsync);
  1408.             }
  1409.         }
  1410.         return request;
  1411.     }
  1412.     function ClearRequest(request)
  1413.     {
  1414.         request.onerror = function(){};
  1415.         request.onload = function(){};
  1416.     }
  1417.     function AsyncCall(command, commandAttribute, data, callbackResult, callbackError, isLongPoolingCall)
  1418.     {
  1419.         try
  1420.         {
  1421.             var request = PrepareRequestObject(command, commandAttribute, data ? true : false, true);
  1422.             if (!request)
  1423.             {
  1424.                 callbackError && callbackError("Cannot create AJAX request!");
  1425.                 return;
  1426.             }
  1427.             if (!m_longPooling)
  1428.             {
  1429.                 var timeout = ns.SetTimeout(function ()
  1430.                     {
  1431.                         callbackError && callbackError("Cannot send AJAX request for calling " + command + "/" + commandAttribute);
  1432.                         request.abort();
  1433.                         ClearRequest(request);
  1434.                     }, 120000);
  1435.             }
  1436.             request.onerror = function ()
  1437.                 {
  1438.                     clearTimeout(timeout);
  1439.                     ClearRequest(request);
  1440.                     callbackError && callbackError("AJAX request error for calling " + command + "/" + commandAttribute);
  1441.                 };
  1442.             request.onload = function ()
  1443.                 {
  1444.                     clearTimeout(timeout);
  1445.                     ClearRequest(request);
  1446.                     if (request.responseText)
  1447.                     {
  1448.                         if (callbackResult)
  1449.                             callbackResult(request.responseText);
  1450.                         return;
  1451.                     }
  1452.                     if (callbackError)
  1453.                         callbackError("AJAX request with unsupported url type!");
  1454.                 };
  1455.             if (isLongPoolingCall)
  1456.                 m_longPoolingRequest = request;
  1457.             request.send(data);
  1458.             ns.Log("Call native function " + command + "/" + commandAttribute);
  1459.         }
  1460.         catch (e)
  1461.         {
  1462.             if (callbackError)
  1463.                 callbackError("AJAX request " + command  + "/" + commandAttribute + " exception: " + (e.message || e));
  1464.         }
  1465.     };
  1466.     function SyncCall(command, commandAttribute, data, callbackResult, callbackError)
  1467.     {
  1468.         try
  1469.         {
  1470.             var request = PrepareRequestObject(command, commandAttribute + "?" + ns.EncodeURI(data), false, false);
  1471.             if (!request)
  1472.             {
  1473.                 callbackError && callbackError("Cannot create AJAX request!");
  1474.                 return false;
  1475.             }
  1476.             request.send();
  1477.             if (request.status === 200)
  1478.             {
  1479.                 if (callbackResult && request.responseText)
  1480.                     callbackResult(request.responseText);
  1481.                 request = null;
  1482.                 return true;
  1483.             }
  1484.         }
  1485.         catch (e)
  1486.         {
  1487.             if (callbackError)
  1488.                 callbackError("AJAX request " + command + " exception: " + (e.message || e));
  1489.         }
  1490.         return false;
  1491.     }
  1492.     this.Start = function(callbackSuccess)
  1493.     {
  1494.         callbackSuccess();
  1495.     }
  1496.     this.SendLog = function(message)
  1497.     {
  1498.         AsyncCall("log?" + encodeURIComponent(message));
  1499.     }
  1500.     this.Call = function(command, commandAttribute, data, isAsync, callbackResult, callbackError, isLongPoolingCall)
  1501.     {
  1502.         var callFunction = (isAsync || !ns.IsDefined(isAsync)) ? AsyncCall : SyncCall;
  1503.         return callFunction(
  1504.             command,
  1505.             commandAttribute,
  1506.             data,
  1507.             function(responseText)
  1508.             {
  1509.                 var commandResponse = ns.JSONParse(responseText);
  1510.                 if (commandResponse.result === -1610612735)
  1511.                 {
  1512.                     callFunction(
  1513.                         command,
  1514.                         commandAttribute,
  1515.                         data,
  1516.                         function(responseText)
  1517.                         {
  1518.                             if (!callbackResult)
  1519.                                 return;
  1520.                             commandResponse = ns.JSONParse(responseText);
  1521.                             callbackResult(commandResponse.result, commandResponse.parameters, commandResponse.method);
  1522.                         },
  1523.                         callbackError,
  1524.                         isLongPoolingCall);
  1525.                 }
  1526.                 else
  1527.                 {
  1528.                     if (callbackResult)
  1529.                         callbackResult(commandResponse.result, commandResponse.parameters, commandResponse.method);
  1530.                 }
  1531.             },
  1532.             callbackError,
  1533.             isLongPoolingCall);
  1534.     }
  1535.     this.Shutdown = function()
  1536.     {
  1537.         if (m_longPoolingRequest != undefined)
  1538.         {
  1539.             m_longPoolingRequest.abort();
  1540.             m_longPoolingRequest = undefined;
  1541.         }
  1542.     }
  1543.     this.InitCall = function(pluginsInitData, callbackResult, callbackError)
  1544.     {
  1545.         restoreSessionCallback = callbackError;
  1546.         var specialPlugins = GetSpecialPlugins(ns.PLUGINS_LIST);
  1547.         var serializedInitData = (pluginsInitData.length) ? "&data=" + encodeURIComponent(ns.JSONStringify({data : pluginsInitData})) : "";
  1548.         var isTopLevel = "&isTopLevel=" + (window && window == window.top).toString();
  1549.         if (ns.StartLocationHref == "data:text/html,chromewebdata")
  1550.             return callbackError();
  1551.         AsyncCall(
  1552.             "init?url=" + encodeURIComponent(ns.StartLocationHref) + specialPlugins + serializedInitData + isTopLevel,
  1553.             null,
  1554.             null,
  1555.             function(responseText)
  1556.             {
  1557.                 try
  1558.                 {
  1559.                     var initSettings = ns.JSONParse(responseText);
  1560.                     m_path = (ns.PREFIX || '/') + initSettings.ajaxId + '/' + initSettings.sessionId;
  1561.                     m_longPooling = initSettings.longPooling;
  1562.                     callbackResult(initSettings);
  1563.                 } catch(e)
  1564.                 {
  1565.                     restoreSessionCallback && restoreSessionCallback("Error " + e.name + ": " + e.message);
  1566.                 }
  1567.             },
  1568.             callbackError);
  1569.     }
  1570.     this.GetReceiver = function()
  1571.     {
  1572.         return m_longPooling ? new LongPoolingReceiver(this) : new PingPongCallReceiver(this);
  1573.     }
  1574. };
  1575. return ns;
  1576. }) (KasperskyLab || {});
  1577. var KasperskyLab = (function ( ns) {
  1578. ns.WebSocketTransportSupported = ns.IsDefined(window.WebSocket);
  1579. if (!ns.WebSocketTransportSupported)
  1580.     return ns;
  1581. var webSocketProvider = function()
  1582.     {
  1583.         var WebSocketObject = WebSocket;
  1584.         var WebSocketSend = WebSocket.prototype.send;
  1585.         var WebSocketClose = WebSocket.prototype.close;
  1586.         return {
  1587.             GetWebSocket: function(path)
  1588.             {
  1589.                 var webSocket = new WebSocketObject(path);
  1590.                 webSocket.send = WebSocketSend;
  1591.                 webSocket.close = WebSocketClose;
  1592.                 return webSocket;
  1593.             }
  1594.         }
  1595.     }();
  1596. ns.WebSocketCaller = function()
  1597. {
  1598.     var m_socket;
  1599.     var m_waitResponse = {};
  1600.     var m_callReceiver = function(){};
  1601.     var m_errorCallback = function(){};
  1602.     var m_callReceiverEnabled = false;
  1603.     var m_connected = false;
  1604.     var m_initialized = false;
  1605.     var m_deferredCalls = [];
  1606.     var m_wasCallbackErrorCalled = false;
  1607.     function GetWebSocket(callbackSuccess, callbackError)
  1608.     {
  1609.         var url = (ns.PREFIX === "/")
  1610.             ? document.location.protocol + "//" + document.location.host + ns.PREFIX
  1611.             : ns.PREFIX;
  1612.         var webSocketPath = (url.indexOf("https:") === 0)
  1613.             ? "wss" + url.substr(5)
  1614.             : "ws" + url.substr(4);
  1615.         webSocketPath += ns.SIGNATURE + "/websocket?url=" + encodeURIComponent(ns.StartLocationHref) + "&nocache=" + (new Date().getTime());
  1616.         var webSocket;
  1617.         try
  1618.         {
  1619.             webSocket = webSocketProvider.GetWebSocket(webSocketPath);
  1620.         }
  1621.         catch (e)
  1622.         {
  1623.             throw e;
  1624.         }
  1625.         webSocket.onmessage = function(arg)
  1626.             {
  1627.                 ProcessMessage(arg, callbackError);
  1628.             };
  1629.         webSocket.onerror = function()
  1630.             {
  1631.                 if (!m_wasCallbackErrorCalled && callbackError)
  1632.                     callbackError();
  1633.                 m_wasCallbackErrorCalled = true;
  1634.             }
  1635.         webSocket.onopen = function()
  1636.             {
  1637.                 m_wasCallbackErrorCalled = false;
  1638.                 m_connected = true;
  1639.                 if (callbackSuccess)
  1640.                     callbackSuccess();
  1641.             }
  1642.         webSocket.onclose = function(closeEvent)
  1643.             {
  1644.                 m_connected = false;
  1645.                 if (closeEvent && closeEvent.code == 1006)
  1646.                     webSocket.onerror(closeEvent);
  1647.                 m_errorCallback("websocket closed");
  1648.             };
  1649.         return webSocket;
  1650.     }
  1651.     function ProcessMessage(arg, errorCallback)
  1652.     {
  1653.         try
  1654.         {
  1655.             m_wasCallbackErrorCalled = false;
  1656.             var response = ns.JSONParse(arg.data);
  1657.             if (m_waitResponse[response.callId])
  1658.             {
  1659.                 var callWaiter = m_waitResponse[response.callId];
  1660.                 delete m_waitResponse[response.callId];
  1661.                 clearTimeout(callWaiter.timeout);
  1662.                 if (callWaiter.callbackResult)
  1663.                     callWaiter.callbackResult(response.commandData);
  1664.                 return;
  1665.             }
  1666.             if (!m_initialized)
  1667.             {
  1668.                 m_deferredCalls.push(arg);
  1669.                 return;
  1670.             }
  1671.             if (response.command === "from")
  1672.             {
  1673.                 var command = ns.JSONParse(response.commandData);
  1674.                 m_callReceiver(command.method, command.parameters);
  1675.             }
  1676.             else if (response.command === "reconnect")
  1677.             {
  1678.                 m_socket.onmessage = function(){};
  1679.                 m_socket.onerror = function(){};
  1680.                 m_socket.onopen = function(){};
  1681.                 m_socket.onclose = function(){};
  1682.                 m_socket.close();
  1683.                 m_socket = GetWebSocket(function()
  1684.                     {
  1685.                         CallImpl("restore", "", response.commandData);
  1686.                     },
  1687.                     errorCallback);
  1688.             }
  1689.         }
  1690.         catch (e)
  1691.         {
  1692.             ns.SessionLog(e)
  1693.         }
  1694.     }
  1695.     function CallImpl(command, commandAttribute, data, callbackResult, callbackError)
  1696.     {
  1697.         try
  1698.         {
  1699.             var callId = 0;
  1700.             if (callbackResult || callbackError)
  1701.             {
  1702.                 callId = Math.floor((1 + Math.random()) * 0x10000);
  1703.                 var timeout = ns.SetTimeout(function()
  1704.                     {
  1705.                         delete m_waitResponse[callId];
  1706.                         if (callbackError)
  1707.                             callbackError("websocket call timeout for " + command  + "/" + commandAttribute);
  1708.                     }, 120000);
  1709.                 var callWaiter =
  1710.                     {
  1711.                         callId: callId,
  1712.                         callbackResult: callbackResult,
  1713.                         timeout: timeout
  1714.                     };
  1715.                 m_waitResponse[callId] = callWaiter;
  1716.             }
  1717.             m_socket.send(ns.JSONStringify(
  1718.                 {
  1719.                     callId: callId,
  1720.                     command: command,
  1721.                     commandAttribute: commandAttribute || "",
  1722.                     commandData: data || ""
  1723.                 }));
  1724.         }
  1725.         catch (e)
  1726.         {
  1727.             if (callbackError)
  1728.                 callbackError("websocket call " + command  + "/" + commandAttribute + " exception: " + (e.message || e));
  1729.         }
  1730.     }
  1731.     this.Start = function(callbackSuccess, callbackError)
  1732.     {
  1733.         try
  1734.         {
  1735.             m_socket = GetWebSocket(callbackSuccess, callbackError);
  1736.         }
  1737.         catch (e)
  1738.         {
  1739.             if (callbackError)
  1740.                 callbackError("websocket start exception: " + (e.message || e));
  1741.         }
  1742.     }
  1743.     this.SendLog = function(message)
  1744.     {
  1745.         CallImpl("log", null, message);
  1746.     }
  1747.     this.Call = function(command, commandAttribute, data, isAsync, callbackResult, callbackError)
  1748.     {
  1749.         if (ns.IsDefined(isAsync) && !isAsync)
  1750.             return false;
  1751.         CallImpl(
  1752.             command,
  1753.             commandAttribute,
  1754.             data,
  1755.             callbackResult
  1756.                 ?   function(responseText)
  1757.                     {
  1758.                         if (callbackResult)
  1759.                         {
  1760.                             var command = ns.JSONParse(responseText);
  1761.                             callbackResult(command.result, command.parameters, command.method);
  1762.                         }
  1763.                     }
  1764.                 : null,
  1765.             callbackError);
  1766.     }
  1767.     this.InitCall = function(pluginsInitData, callbackResult, callbackError)
  1768.     {
  1769.         var initData =
  1770.             {
  1771.                 url: ns.StartLocationHref,
  1772.                 plugins: ns.PLUGINS_LIST,
  1773.                 data: { data : pluginsInitData },
  1774.                 isTopLevel: (window && window == window.top)
  1775.             };
  1776.         if (ns.StartLocationHref == "data:text/html,chromewebdata")
  1777.             return callbackError();
  1778.         CallImpl("init", null, ns.JSONStringify(initData),
  1779.             function(responseText)
  1780.             {
  1781.                 m_initialized = true;
  1782.                 var initSettings = ns.JSONParse(responseText);
  1783.                 if (initSettings.Shutdown !== undefined)
  1784.                     return;
  1785.                 callbackResult(initSettings);
  1786.                 for (var i = 0; i < m_deferredCalls.length; ++i)
  1787.                     ProcessMessage(m_deferredCalls[i], callbackError);
  1788.                 m_deferredCalls = [];
  1789.             },
  1790.             callbackError);
  1791.     }
  1792.     this.GetReceiver = function()
  1793.     {
  1794.         return this;
  1795.     }
  1796.     this.StartReceive = function(callMethod, errorCallback)
  1797.     {
  1798.         m_callReceiverEnabled = true;
  1799.         m_callReceiver = callMethod;
  1800.         m_errorCallback = errorCallback;
  1801.     }
  1802.     this.ForceReceive = function(){};
  1803.     this.StopReceive = function()
  1804.     {
  1805.         m_callReceiverEnabled = false;
  1806.         m_callReceiver = function(){};
  1807.         m_errorCallback = function(){};
  1808.         if (m_socket)
  1809.         {
  1810.             m_connected = false;
  1811.             m_socket.onmessage = function(){};
  1812.             m_socket.onerror = function(){};
  1813.             m_socket.onopen = function(){};
  1814.             m_socket.onclose = function(){};
  1815.             m_socket.close();
  1816.             m_socket = null;
  1817.         }
  1818.     }
  1819.     this.IsStarted = function()
  1820.     {
  1821.         return m_callReceiverEnabled;
  1822.     }
  1823.     this.IsProductConnected = function()
  1824.     {
  1825.         return m_connected;
  1826.     }
  1827. }
  1828. return ns;
  1829. }) (KasperskyLab || {});
  1830. var kaspersyLabSessionInstance = null;
  1831. (function ( ns) {
  1832.     var currentLocationHref = document.location.href;
  1833.     if (ns.WORK_IDENTIFIERS)
  1834.     {
  1835.         var workIdentifiers = ns.WORK_IDENTIFIERS.split(",");
  1836.         for (var i = 0; i < workIdentifiers.length; ++i)
  1837.             window[workIdentifiers[i]] = true;
  1838.     }
  1839.     if (ns.INJECT_ID)
  1840.         removeThisScriptElement(ns.INJECT_ID);
  1841.     function removeThisScriptElement(injectId)
  1842.     {
  1843.         var pattern = injectId.toLowerCase();
  1844.         for (var i = 0, scriptsCount = document.scripts.length; i < scriptsCount; ++i)
  1845.         {
  1846.             var tag = document.scripts[i];
  1847.             if (typeof tag.src === 'string' && tag.src.length > 45 &&
  1848.                 tag.src.toLowerCase().indexOf(pattern) > 0 &&
  1849.                 /\/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\/main.js/.test(tag.src))
  1850.             {
  1851.                 tag.parentElement.removeChild(tag);
  1852.                 break;
  1853.             }
  1854.         }
  1855.     }
  1856.     var CallReceiver = function (caller) {
  1857.         var m_plugins = {};
  1858.         var m_receiver = caller.GetReceiver();
  1859.         var m_caller = caller;
  1860.         this.RegisterMethod = function (methodName, callback) {
  1861.             var pluginId = GetPluginIdFromMethodName(methodName);
  1862.             if (pluginId) {
  1863.                 var methods = GetPluginMethods(pluginId);
  1864.                 if (methods) {
  1865.                     if (methods[methodName]) {
  1866.                         throw 'Already registered method ' + methodName;
  1867.                     }
  1868.                     methods[methodName] = callback;
  1869.                 }
  1870.                 else {
  1871.                     throw 'Cannot registered ' + methodName;
  1872.                 }
  1873.             }
  1874.         };
  1875.         this.RegisterPlugin = function (pluginId, callbackPing, callbackError) {
  1876.             if (m_plugins[pluginId]) {
  1877.                 throw 'Already started plugin ' + pluginId;
  1878.             }
  1879.             var plugin = {
  1880.                 onError: callbackError,
  1881.                 onPing: callbackPing,
  1882.                 methods: {}
  1883.             };
  1884.             m_plugins[pluginId] = plugin;
  1885.             if (!m_receiver.IsStarted())
  1886.                 m_receiver.StartReceive(CallMethod, ReportError, UpdateDelay);
  1887.         };
  1888.         this.UnregisterPlugin = function (pluginId) {
  1889.             delete m_plugins[pluginId];
  1890.             if (IsPluginListEmpty())
  1891.                 m_receiver.StopReceive();
  1892.         };
  1893.         this.ForceReceive = function()
  1894.         {
  1895.             m_receiver.ForceReceive();
  1896.         }
  1897.         this.UnregisterAll = function () {
  1898.             if (IsPluginListEmpty())
  1899.                 return;
  1900.             m_receiver.StopReceive();
  1901.             m_plugins = {};
  1902.         };
  1903.         this.IsEmpty = IsPluginListEmpty;
  1904.         function IsPluginListEmpty() {
  1905.             for (var key in m_plugins) {
  1906.                 if (m_plugins.hasOwnProperty(key))
  1907.                     return false;
  1908.             }
  1909.             return true;
  1910.         }
  1911.         this.IsProductConnected = function()
  1912.         {
  1913.             return m_receiver.IsProductConnected();
  1914.         }
  1915.         function UpdateDelay() {
  1916.             var newDelay = ns.MaxRequestDelay;
  1917.             var currentTime = ns.GetCurrentTime();
  1918.             for (var pluginId in m_plugins) {
  1919.                 try {
  1920.                     var onPing = m_plugins[pluginId].onPing;
  1921.                     if (onPing) {
  1922.                         var delay = onPing(currentTime);
  1923.                         if (delay < newDelay && delay > 0 && delay < ns.MaxRequestDelay) {
  1924.                             newDelay = delay;
  1925.                         }
  1926.                     }
  1927.                 }
  1928.                 catch (e) {
  1929.                     ReportPluginError(pluginId, 'UpdateDelay: ' + (e.message || e));
  1930.                 }
  1931.             }
  1932.             return newDelay;
  1933.         }
  1934.         function ReportPluginError(pluginId, status) {
  1935.             var onError = m_plugins[pluginId].onError;
  1936.             if (onError)
  1937.                 onError(status);
  1938.         }
  1939.         function ReportError(status) {
  1940.             for (var pluginId in m_plugins)
  1941.                 ReportPluginError(pluginId, status);
  1942.         }
  1943.         function GetPluginIdFromMethodName(methodName) {
  1944.             if (methodName) {
  1945.                 var names = methodName.split('.', 2);
  1946.                 if (names.length === 2) {
  1947.                     return names[0];
  1948.                 }
  1949.             }
  1950.             return null;
  1951.         }
  1952.         function GetPluginMethods(pluginId) {
  1953.             var plugin = m_plugins[pluginId];
  1954.             return plugin ? plugin.methods : null;
  1955.         }
  1956.         function CallPluginMethod(pluginId, methodName, args) {
  1957.             var methods = GetPluginMethods(pluginId);
  1958.             if (methods) {
  1959.                 var callback = methods[methodName];
  1960.                 if (callback) {
  1961.                     try {
  1962.                         callback(args);
  1963.                         m_caller.SendLog(methodName + " executed.");
  1964.                         return true;
  1965.                     }
  1966.                     catch (e) {
  1967.                         m_caller.SendLog("Call " + methodName + " in plugin " + pluginId + " error: " + (e.message || e));
  1968.                     }
  1969.                 }
  1970.             }
  1971.             m_caller.SendLog("Cannot call " + methodName + " for plugin " + pluginId);
  1972.             return false;
  1973.         }
  1974.         function CallMethod(methodName, args)
  1975.         {
  1976.             ns.Log("Try to find js callback " + methodName);
  1977.             var pluginId = GetPluginIdFromMethodName(methodName);
  1978.             if (pluginId)
  1979.                 CallPluginMethod(pluginId, methodName, args);
  1980.         }
  1981.     };
  1982.     var KasperskyLabSessionClass = function (caller) {
  1983.         var self = this;
  1984.         var m_caller = caller;
  1985.         var m_callReceiver = new CallReceiver(caller);
  1986.         function CallImpl(methodName, arrayOfArgs, callbackResult, callbackError, isAsync) {
  1987.             var data = (arrayOfArgs && arrayOfArgs.length)
  1988.                 ? ns.JSONStringify(
  1989.                     {
  1990.                         result: 0,
  1991.                         method: methodName,
  1992.                         parameters: arrayOfArgs
  1993.                     })
  1994.                 : null;
  1995.             return m_caller.Call("to", methodName, data, isAsync, callbackResult, callbackError);
  1996.         }
  1997.         function Call(methodName, arrayOfArgs, callbackResult, callbackError) {
  1998.             CallImpl(methodName, arrayOfArgs, callbackResult, callbackError, true);
  1999.         }
  2000.         function SyncCall(methodName, arrayOfArgs, callbackResult, callbackError) {
  2001.             return CallImpl(methodName, arrayOfArgs, callbackResult, callbackError, false);
  2002.         }
  2003.         function Stop() {
  2004.             try {
  2005.                 m_callReceiver.UnregisterAll();
  2006.                 ns.Log("session stopped");
  2007.                 if (m_callReceiver.IsProductConnected())
  2008.                 {
  2009.                     if (!m_caller.Call("shutdown", null, null, false))
  2010.                         m_caller.Call("shutdown");
  2011.                 }
  2012.                 if (m_caller.Shutdown)
  2013.                     m_caller.Shutdown();               
  2014.             }
  2015.             catch (e) {
  2016.             }
  2017.         }
  2018.         function DeactivatePlugin(pluginId) {
  2019.             ns.Log('DeactivatePlugin ' + pluginId);
  2020.             m_callReceiver.UnregisterPlugin(pluginId);
  2021.             if (m_callReceiver.IsEmpty()) {
  2022.                 Stop();
  2023.             }
  2024.         }
  2025.         function ActivatePlugin(pluginId, callbackPing, callbackError) {
  2026.             ns.Log('ActivatePlugin ' + pluginId);
  2027.             m_callReceiver.RegisterPlugin(pluginId, callbackPing, function (e) {
  2028.                 callbackError && callbackError(e);
  2029.                 m_callReceiver.UnregisterPlugin(pluginId);
  2030.                 if (m_callReceiver.IsEmpty()) {
  2031.                     Stop();
  2032.                 }
  2033.             });
  2034.         }
  2035.         function RegisterMethod(methodName, callback) {
  2036.             ns.Log('RegisterMethod ' + methodName);
  2037.             m_callReceiver.RegisterMethod(methodName, callback);
  2038.         }
  2039.         this.Log = function(error)
  2040.         {
  2041.             try
  2042.             {
  2043.                 var msg = "" + (error.message || error);
  2044.                 if (error.stack)
  2045.                     msg += "\r\n" + error.stack;
  2046.                 msg && msg.length <= 2048 ? m_caller.SendLog(msg) : m_caller.SendLog(msg.substring(0, 2048) + '<...>');
  2047.             }
  2048.             catch(e)
  2049.             {
  2050.                 ns.Log(e.message || e);
  2051.             }
  2052.         };
  2053.         this.ForceReceive = function()
  2054.         {
  2055.             m_callReceiver.ForceReceive();
  2056.         }
  2057.         this.InitializePlugin = function (init) {
  2058.             init(
  2059.                 function () {
  2060.                     ActivatePlugin.apply(self, arguments);
  2061.                 },
  2062.                 function () {
  2063.                     RegisterMethod.apply(self, arguments);
  2064.                 },
  2065.                 function () {
  2066.                     Call.apply(self, arguments);
  2067.                 },
  2068.                 function () {
  2069.                     DeactivatePlugin.apply(self, arguments);
  2070.                 },
  2071.                 function () {
  2072.                     return SyncCall.apply(self, arguments);
  2073.                 }
  2074.             );
  2075.         };
  2076.         ns.AddEventListener(window, "unload", function()
  2077.             {
  2078.                 if (!m_callReceiver.IsEmpty())
  2079.                     Stop();
  2080.             });
  2081.     };
  2082.     var runners = {};
  2083.     var pluginsInitData = [];
  2084.     ns.AddRunner = function(pluginName, runnerFunc, initParameters)
  2085.     {
  2086.         runners[pluginName] = runnerFunc;
  2087.         if (initParameters)
  2088.         {
  2089.             pluginsInitData.push({plugin: pluginName, parameters: initParameters});
  2090.         }
  2091.     };
  2092.     ns.SessionLog = function(e)
  2093.     {
  2094.         if (kaspersyLabSessionInstance)
  2095.             kaspersyLabSessionInstance.Log(e);
  2096.     }
  2097.     ns.ContentSecurityPolicyNonceAttribute = ns.CSP_NONCE;
  2098.     var SupportedCallerProvider = function()
  2099.     {
  2100.         var m_current = 0;
  2101.         var m_supportedCallers = [];
  2102.         if (ns.WebSocketTransportSupported)
  2103.             m_supportedCallers.push(new ns.WebSocketCaller);
  2104.         if (ns.AjaxTransportSupported)
  2105.             m_supportedCallers.push(new ns.AjaxCaller);
  2106.         function FindSupportedImpl(callbackSuccess)
  2107.         {
  2108.             if (m_current < m_supportedCallers.length)
  2109.             {
  2110.                 var caller = m_supportedCallers[m_current++];
  2111.                 caller.Start(function(){callbackSuccess(caller);}, function(){FindSupportedImpl(callbackSuccess);});
  2112.             }
  2113.             else
  2114.             {
  2115.                 m_current = 0;
  2116.                 PostponeInit();
  2117.             }
  2118.         }
  2119.         this.FindSupported = function(callbackSuccess)
  2120.         {
  2121.             FindSupportedImpl(callbackSuccess);
  2122.         }
  2123.     }
  2124.     function Init()
  2125.     {
  2126.         var callerProvider = new SupportedCallerProvider;
  2127.         callerProvider.FindSupported(
  2128.             function(caller)
  2129.             {
  2130.                 caller.InitCall(
  2131.                     pluginsInitData,
  2132.                     function(initSettings)
  2133.                     {
  2134.                         ns.IsRtl = initSettings.rtl;
  2135.                         ns.RES_SIGNATURE = initSettings.resSignature;
  2136.                         ns.GetResourceSrc = function (resourceName)
  2137.                         {
  2138.                             return ns.PREFIX + ns.RES_SIGNATURE + resourceName;
  2139.                         };
  2140.                         ns.GetCommandSrc = function()
  2141.                         {
  2142.                             return (ns.PREFIX || "/") + initSettings.ajaxId + "/" + initSettings.sessionId;
  2143.                         }
  2144.                         kaspersyLabSessionInstance = new KasperskyLabSessionClass(caller);
  2145.                         var plugins = initSettings.plugins;
  2146.                         for (var i = 0, pluginsCount = plugins.length; i < pluginsCount; ++i)
  2147.                         {
  2148.                             var plugin = plugins[i];
  2149.                             var pluginRunnerFunction = runners[plugin.name];
  2150.                             if (pluginRunnerFunction)
  2151.                                 pluginRunnerFunction(KasperskyLab, kaspersyLabSessionInstance, plugin.settings, plugin.localization);
  2152.                         }
  2153.                     },
  2154.                     function()
  2155.                     {
  2156.                         PostponeInit();
  2157.                     });
  2158.             });
  2159.     }
  2160.     var lastPostponedInitTime = (new Date()).getTime();
  2161.     var postponedInitTimeout = null;
  2162.     function PostponeInit()
  2163.     {
  2164.         var nowPostponeTime = (new Date()).getTime();
  2165.         var postponeDelay = (nowPostponeTime - lastPostponedInitTime) > 5000 ? 200 : 60 * 1000;
  2166.         lastPostponedInitTime = nowPostponeTime;
  2167.         clearTimeout(postponedInitTimeout)
  2168.         postponedInitTimeout = ns.SetTimeout(function () { Init(); }, postponeDelay);
  2169.     }
  2170.     ns.SetTimeout(function () { Init(); }, 0);
  2171. })(KasperskyLab);
  2172. (function (ns)
  2173. {
  2174. ns.waitForApiInjection = function(isApiInjected, eventName, callback)
  2175. {
  2176.     if (isApiInjected())
  2177.     {
  2178.         callback();
  2179.         return;
  2180.     }
  2181.     var subscription = createSubscription(eventName, onApiInjected)
  2182.     function onApiInjected()
  2183.     {
  2184.         if (isApiInjected())
  2185.         {
  2186.             subscription.unsubscribe();
  2187.             callback();
  2188.         }
  2189.     }
  2190. }
  2191. function createSubscription(eventName, callback)
  2192. {
  2193.     var windowEventsSupported = document.createEvent || window.addEventListener;
  2194.     return new (windowEventsSupported ? ModernSubscription : IeLegacySubscription)(eventName, callback);
  2195. }
  2196. function ModernSubscription(eventName, callback)
  2197. {
  2198.     ns.AddRemovableEventListener(window, eventName, callback);
  2199.     this.unsubscribe = function()
  2200.     {
  2201.         ns.RemoveEventListener(window, eventName, callback);
  2202.     }
  2203. }
  2204. function IeLegacySubscription(eventName, callback)
  2205. {
  2206.     ns.AddRemovableEventListener(document.documentElement, 'propertychange', onPropertyChange);
  2207.     this.unsubscribe = function()
  2208.     {
  2209.         ns.RemoveEventListener(document.documentElement, 'propertychange', onPropertyChange);
  2210.     }
  2211.     function onPropertyChange(event)
  2212.     {
  2213.         if (event.propertyName == eventName)
  2214.             callback();
  2215.     }
  2216. }
  2217. })(KasperskyLab || {});
  2218. var tabIdPropertyName = KasperskyLab.LIGHT_PLUGIN_API_KEY || 'klTabId_kis';
  2219. var scriptPluginId = Math.floor((1 + Math.random()) * 0x10000).toString(16);
  2220. function isApiInjected()
  2221. {
  2222.     return !!window[tabIdPropertyName];
  2223. }
  2224. function makeTopLevelArgument()
  2225. {
  2226.     return window == window.top ? 'true' : 'false';
  2227. }
  2228. function removeTabIdProperty()
  2229. {
  2230.     try {
  2231.         delete window[tabIdPropertyName];
  2232.     } catch (e) {
  2233.         window[tabIdPropertyName] = undefined;
  2234.     }  
  2235. }
  2236. var documentInitParameters = isApiInjected() ? [String(window[tabIdPropertyName]), makeTopLevelArgument(), scriptPluginId] : null;
  2237. KasperskyLab.AddRunner("light_doc", function (ns, session)
  2238. {
  2239. session.InitializePlugin(function(activatePlugin, _, callFunction)
  2240. {
  2241.     activatePlugin('light_doc');
  2242.    
  2243.     if (documentInitParameters)
  2244.     {
  2245.         removeTabIdProperty();
  2246.         return;
  2247.     }
  2248.    
  2249.     ns.waitForApiInjection(isApiInjected, tabIdPropertyName, function()
  2250.     {
  2251.         var tabId = String(window[tabIdPropertyName]);
  2252.         removeTabIdProperty();
  2253.         callFunction("light_doc.registerDocument", [
  2254.             tabId,
  2255.             document.URL,
  2256.             makeTopLevelArgument(),
  2257.             scriptPluginId
  2258.             ]);
  2259.     });
  2260. });
  2261. }, documentInitParameters);
  2262. (function (ns)
  2263. {
  2264. ns.IsPositionEqual = function(prevPos, currentPos)
  2265. {
  2266.     return prevPos && currentPos && prevPos.top === currentPos.top && prevPos.left === currentPos.left;
  2267. };
  2268. ns.GetAbsoluteElementPosition = function(element)
  2269. {
  2270.     var box = element.getBoundingClientRect();
  2271.     var scroll = ns.GetPageScroll();
  2272.     return {
  2273.             left: box.left + scroll.left,
  2274.             top: box.top + scroll.top,
  2275.             right: box.right + scroll.left,
  2276.             bottom: box.bottom + scroll.top
  2277.         };
  2278. };
  2279. })(KasperskyLab || {});
  2280. (function (ns)
  2281. {
  2282. ns.ProtectableElementDetector = function(protectMode)
  2283. {
  2284.     var m_typesForbidden = ['hidden', 'submit', 'radio', 'checkbox', 'button', 'image'];
  2285.     var m_protectMode = protectMode;
  2286.     this.Test = function(element)
  2287.     {
  2288.         if (m_protectMode < 2 || m_protectMode > 3)
  2289.             return false;
  2290.         var elementType = element.getAttribute('type');
  2291.         elementType = elementType && elementType.toLowerCase();
  2292.         if (m_protectMode === 2)
  2293.         {
  2294.             if (elementType != 'password')
  2295.                 return false;
  2296.         }
  2297.         else if (Includes(m_typesForbidden, elementType))
  2298.         {
  2299.             return false;
  2300.         }
  2301.         if (GetComputedStyle(element, 'display') === 'none')
  2302.             return false;
  2303.         var maxLength = parseInt(element.getAttribute('maxlength'), 10);
  2304.         return typeof maxLength === 'number' && maxLength <= 3 ? false : !element.readOnly;
  2305.     };
  2306.     function Includes(list, text)
  2307.     {
  2308.         var i = 0, count = list.length;
  2309.         for (; i < count; ++i)
  2310.             if (list[i] === text)
  2311.                 return true;
  2312.         return false;
  2313.     }
  2314.     function GetComputedStyle(element, property)
  2315.     {
  2316.         var value;
  2317.         if (element.currentStyle)
  2318.         {
  2319.             value = element.currentStyle[property];
  2320.         }
  2321.         else
  2322.         {
  2323.             var styles = window.getComputedStyle(element, '');
  2324.             if (styles)
  2325.                 value = styles.getPropertyValue(property);
  2326.         }
  2327.         return typeof value !== 'string' ? '' : value.toLowerCase();
  2328.     }
  2329. }
  2330. })(KasperskyLab || {});
  2331. (function (ns)
  2332. {
  2333. ns.SecureInputTooltip = function(locales, session)
  2334. {
  2335.     var m_balloon = new ns.Balloon2("vk_si", "/vk/secure_input_tooltip.html", "/vk/secure_input_tooltip.css", session, GetCoords, OnCloseHandler, locales);
  2336.     var m_currentElement = null;
  2337.     var m_timer;
  2338.     var that = this;
  2339.     var Top = 0;
  2340.     var Bottom = 1;
  2341.     var m_lastTooltipPosition = Bottom;
  2342.     function GetClassName(position)
  2343.     {
  2344.         if (position === Top)
  2345.             return "top_balloon";
  2346.         else if (position === Bottom)
  2347.             return "bottom_balloon";
  2348.         else
  2349.             return null;
  2350.     }
  2351.     function UpdateBalloon()
  2352.     {
  2353.         if (!m_balloon)
  2354.             return;
  2355.         m_balloon.Update(GetClassName(m_lastTooltipPosition));
  2356.     }
  2357.     function SetPosition(position)
  2358.     {
  2359.         if (m_lastTooltipPosition === position)
  2360.             return;
  2361.         m_lastTooltipPosition = position;
  2362.         UpdateBalloon();
  2363.     }
  2364.     function GetCoords(tooltipSize)
  2365.     {
  2366.         if (!m_timer)
  2367.         {
  2368.             m_timer = ns.SetInterval(UpdateBalloonByTimer, 100);
  2369.             ns.SetTimeout(function () { that.Hide(); }, 3000);
  2370.         }
  2371.         var inputPosition = ns.GetAbsoluteElementPosition(m_currentElement);
  2372.         var coords = {x: inputPosition.left, y: inputPosition.top};
  2373.         var inputTopRelative = inputPosition.top - ns.GetPageScroll().top;
  2374.         var clientHeightUnderInput = ns.GetPageHeight() - inputTopRelative - m_currentElement.offsetHeight;
  2375.         if ((clientHeightUnderInput > tooltipSize.height - 1) ||
  2376.             (inputPosition.top - tooltipSize.height + 1 < 0))
  2377.         {
  2378.             coords.y = inputPosition.top + m_currentElement.offsetHeight - 1;
  2379.             SetPosition(Top);
  2380.         }
  2381.         else
  2382.         {
  2383.             coords.y = inputPosition.top - tooltipSize.height + 1;
  2384.             SetPosition(Bottom);
  2385.         }
  2386.         return coords;
  2387.     }
  2388.     function UpdateBalloonByTimer()
  2389.     {
  2390.         if (!m_balloon)
  2391.             return;
  2392.         m_balloon.UpdatePosition();
  2393.     }
  2394.     function RestoreFocusForLastElement()
  2395.     {
  2396.         if (m_currentElement)
  2397.             m_currentElement.focus();
  2398.     }
  2399.     function OnCloseHandler(closeAction)
  2400.     {
  2401.         switch(closeAction)
  2402.         {
  2403.         case 1:
  2404.             ns.SetTimeout(RestoreFocusForLastElement, 0);
  2405.             break;
  2406.         default:
  2407.             ns.SessionLog("Unknown close action " + closeAction);
  2408.             break;
  2409.         };
  2410.     }
  2411.     this.Show = function(element)
  2412.     {
  2413.         m_currentElement = element;
  2414.         m_balloon.Show();
  2415.         this.Hide = function()
  2416.         {
  2417.             clearInterval(m_timer);
  2418.             ns.SetTimeout(function(){m_balloon.Hide();}, 200);
  2419.             this.Show = function(){};
  2420.             this.Hide = function(){};
  2421.         };
  2422.     };
  2423.     this.Hide = function(){};
  2424. };
  2425. })(KasperskyLab || {});
  2426. (function (ns)
  2427. {
  2428. ns.VirtualKeyboardInputIcon = function(clickCallback, session)
  2429. {
  2430.     var m_element;
  2431.     var m_positionTimer;
  2432.     var m_visible = false;
  2433.     var m_balloon = new ns.Balloon2("vk_icon", "/vk/virtual_keyboard_input_icon.html", "/vk/virtual_keyboard_icon.css", session, GetCoords, null, null, DataReceive);
  2434.     var m_iconHideTimer;
  2435.     function ControlIconDisplaying(e)
  2436.     {
  2437.         try
  2438.         {
  2439.             var eventArg = e || window.event;
  2440.             if (eventArg.keyCode === 9 || eventArg.keyCode === 16)
  2441.                 return;
  2442.             if (m_element.value === "")
  2443.                 ShowInternal();
  2444.             else
  2445.                 HideInternal();
  2446.         }
  2447.         catch (e)
  2448.         {
  2449.             ns.SessionLog(e);
  2450.         }
  2451.     }
  2452.     function HideInternal()
  2453.     {
  2454.         if (!m_visible)
  2455.             return;
  2456.         clearInterval(m_positionTimer);
  2457.         m_balloon.Hide();
  2458.         m_visible = false;
  2459.     }
  2460.     function ShowInternal()
  2461.     {
  2462.         if (m_visible)
  2463.             return;
  2464.         m_balloon.Show();
  2465.         m_balloon.UpdatePosition();
  2466.         m_positionTimer = ns.SetInterval(UpdateIconByTimer, 100);
  2467.         m_visible = true;
  2468.     }
  2469.     function UpdateIconByTimer()
  2470.     {
  2471.         m_balloon.UpdatePosition();
  2472.     }
  2473.     function DataReceive(data)
  2474.     {
  2475.         if (data.showKeyboard && m_element)
  2476.             clickCallback();
  2477.     }
  2478.     function GetCoords(tooltipSize)
  2479.     {
  2480.         var inputPosition = ns.GetAbsoluteElementPosition(m_element);
  2481.         var coords = {x: inputPosition.left + m_element.offsetWidth - 20, y: inputPosition.top + (m_element.offsetHeight - 16) / 2};
  2482.         return coords;
  2483.     }  
  2484.     this.Show = function(element)
  2485.     {
  2486.         m_element = element;
  2487.         clearTimeout(m_iconHideTimer);
  2488.         ShowInternal();
  2489.         ns.AddRemovableEventListener(m_element, "keyup", ControlIconDisplaying)
  2490.         this.Hide = function()
  2491.         {
  2492.             m_iconHideTimer = ns.SetTimeout(function(){HideInternal();}, 500);
  2493.             this.Hide = function(){};
  2494.             ns.RemoveEventListener(m_element, "keyup", ControlIconDisplaying);
  2495.         };
  2496.     };
  2497.     this.Hide = function(){};
  2498. };
  2499. })(KasperskyLab || {});
  2500. KasperskyLab.AddRunner("vk", function (ns, session, settings, locales)
  2501. {
  2502. var VirtualKeyboard = function()
  2503. {
  2504.     var m_callFunction, m_syncCallFunction;
  2505.     var m_virtualKeyboardIconShowMode = 0;
  2506.     var m_secureInputProtectMode = 0;
  2507.     var m_activeElement = null;
  2508.     var m_lastFocusedElement = null;
  2509.     var m_protectedState = 0;
  2510.     var m_enabledSecureInput = false;
  2511.     var m_protectChangeTimeout;
  2512.     var m_protectableVirtualKeyboardChecker = new ns.ProtectableElementDetector(settings.vkProtectMode);
  2513.     var m_protectableSecureInputChecker = null;
  2514.     var m_protectableVirtualKeyboardIconChecker = null;
  2515.     var m_attributeName = "vk_" + Math.floor((1 + Math.random()) * 0x10000).toString(16);
  2516.     function ShowVirtualKeyboard()
  2517.     {
  2518.         if (m_lastFocusedElement)
  2519.             m_lastFocusedElement.focus();
  2520.         m_callFunction("vk.showKeyboard");
  2521.     }
  2522.     var m_tooltip = new ns.SecureInputTooltip(locales, session);
  2523.     var m_icon = new ns.VirtualKeyboardInputIcon(ShowVirtualKeyboard, session);
  2524.     var m_postponeStart;
  2525.     var m_shutdown = false;
  2526.     session.InitializePlugin(function (activatePlugin, registerMethod, callFunction, deactivatePlugin, syncCallFunction) {
  2527.         m_callFunction = callFunction;
  2528.         m_syncCallFunction = syncCallFunction;
  2529.         activatePlugin('vk', OnPing);
  2530.         registerMethod('vk.settings', SetSettings);
  2531.     });
  2532.     function OnPing()
  2533.     {
  2534.         return (m_protectedState == 1 || m_protectedState == 2) ? 500 : ns.MaxRequestDelay;
  2535.     }
  2536.     function SetSettings(argumentList)
  2537.     {
  2538.         var newVirtualKeyboardIconShowMode = parseInt(argumentList[0], 10);
  2539.         var newSecureInputProtectMode = parseInt(argumentList[1], 10);
  2540.         SetSettingsImpl(newVirtualKeyboardIconShowMode, newSecureInputProtectMode);
  2541.     }
  2542.     function SetSettingsImpl(newVirtualKeyboardIconShowMode, newSecureInputProtectMode)
  2543.     {
  2544.         if (newSecureInputProtectMode != m_secureInputProtectMode)
  2545.             m_protectableSecureInputChecker = new ns.ProtectableElementDetector(newSecureInputProtectMode);
  2546.         if (newVirtualKeyboardIconShowMode != m_virtualKeyboardIconShowMode)
  2547.             m_protectableVirtualKeyboardIconChecker = new ns.ProtectableElementDetector(newVirtualKeyboardIconShowMode);
  2548.         var needToUpdate = (newSecureInputProtectMode > m_secureInputProtectMode ||
  2549.             newVirtualKeyboardIconShowMode > m_virtualKeyboardIconShowMode);
  2550.         m_secureInputProtectMode = newSecureInputProtectMode;
  2551.         m_virtualKeyboardIconShowMode = newVirtualKeyboardIconShowMode;
  2552.         if (needToUpdate && m_observer)
  2553.             m_observer.settingsChanged();
  2554.     }
  2555.     function NeedProtectElement(element)
  2556.     {
  2557.         return m_protectableSecureInputChecker.Test(element) || m_protectableVirtualKeyboardChecker.Test(element);
  2558.     }
  2559.     function HandleStartProtectCallback(result, args, needSecureInputCall)
  2560.     {
  2561.         if (m_protectedState === 3)
  2562.         {
  2563.             if (result === 0)
  2564.                 StopProtect();
  2565.             else
  2566.                 m_protectedState = 0;  
  2567.             return;
  2568.         }
  2569.         if (result === 0)
  2570.         {
  2571.             if (!args || args.length < 1)
  2572.             {
  2573.                 session.Log("ERR VK - unexpected arguments");
  2574.                 return;
  2575.             }
  2576.             m_enabledSecureInput = args[0] === "true";
  2577.             m_protectedState = 2;  
  2578.             var needSecureInput = m_protectableSecureInputChecker.Test(m_activeElement);
  2579.             if (needSecureInput === needSecureInputCall)
  2580.                 ShowBalloons();
  2581.             else
  2582.                 CheckProtectModeAndShowBalloons();
  2583.             return;
  2584.         }
  2585.         else if (result === 1)
  2586.         {
  2587.             m_postponeStart = ns.SetTimeout(function() { OnElementFocus(m_activeElement); }, 100);
  2588.         }
  2589.         m_protectedState = 0;  
  2590.     }
  2591.     function OnError(e)
  2592.     {
  2593.         session.Log('ERR VK - ' + (e.message || e));
  2594.     }
  2595.     function StartProtect()
  2596.     {
  2597.         if (!document.hasFocus())
  2598.         {
  2599.             m_protectedState = 0;      
  2600.             ns.SessionLog("No focus on StartProtect");
  2601.             return;
  2602.         }
  2603.         var needSecureInput = m_protectableSecureInputChecker.Test(m_activeElement);
  2604.         m_protectedState = 1;  
  2605.         m_callFunction("vk.startProtect", [needSecureInput.toString()], function(result, args) { HandleStartProtectCallback(result, args, needSecureInput);}, OnError);
  2606.     }
  2607.     function ChangeMode()
  2608.     {
  2609.         var needSecureInput = m_protectableSecureInputChecker.Test(m_activeElement);
  2610.         m_protectedState = 1;  
  2611.         m_callFunction("vk.changeMode", [needSecureInput.toString()], function(result, args) { HandleStartProtectCallback(result, args, needSecureInput);}, OnError);
  2612.     }
  2613.     function StopProtect()
  2614.     {
  2615.         m_protectedState = 3;  
  2616.         m_callFunction("vk.stopProtect", [], function (result)
  2617.             {
  2618.                 if (m_protectedState === 1 && result === 0)
  2619.                 {
  2620.                     StartProtect();
  2621.                     return;
  2622.                 }
  2623.                 m_protectedState = 0;      
  2624.             }, OnError);
  2625.     }
  2626.     function ShowBalloons()
  2627.     {
  2628.         if (m_enabledSecureInput)
  2629.             m_tooltip.Show(m_activeElement);
  2630.         if (m_protectableVirtualKeyboardIconChecker.Test(m_activeElement))
  2631.             m_icon.Show(m_activeElement);
  2632.     }
  2633.     function CheckProtectModeAndShowBalloons()
  2634.     {
  2635.         var needSecureInput = m_protectableSecureInputChecker.Test(m_activeElement);
  2636.         if (needSecureInput != m_enabledSecureInput)
  2637.             ChangeMode();
  2638.         else
  2639.             ShowBalloons();
  2640.     }
  2641.     function OnElementFocus(element)
  2642.     {
  2643.         if (m_shutdown)
  2644.             return;
  2645.         if (!NeedProtectElement(element))
  2646.             return;
  2647.         m_activeElement = element;
  2648.         m_lastFocusedElement = element;
  2649.         clearTimeout(m_postponeStart);
  2650.         clearTimeout(m_protectChangeTimeout);
  2651.         m_protectChangeTimeout = ns.SetTimeout(function () { ProcessFocus(); }, 0);
  2652.     }
  2653.     function OnElementBlur(element)
  2654.     {
  2655.         if (m_shutdown)
  2656.             return;
  2657.         clearTimeout(m_postponeStart);
  2658.         m_icon.Hide();
  2659.         m_tooltip.Hide();
  2660.         clearTimeout(m_protectChangeTimeout);
  2661.         m_protectChangeTimeout = ns.SetTimeout(function () { ProcessBlur(); }, 0);
  2662.     }
  2663.     function OnSettingsChanged(element)
  2664.     {
  2665.         var needProtectElement = NeedProtectElement(element);
  2666.         if ((m_activeElement !== element) ^ needProtectElement)
  2667.             return;
  2668.         if (needProtectElement)
  2669.             OnElementFocus(element);
  2670.         else
  2671.             OnElementBlur(element);
  2672.     }
  2673.     function ProcessFocus()
  2674.     {
  2675.         if (m_protectedState === 0)        
  2676.             StartProtect();
  2677.         else if (m_protectedState === 2)    
  2678.             CheckProtectModeAndShowBalloons();
  2679.         else if (m_protectedState === 3)   
  2680.             m_protectedState = 1;          
  2681.     }
  2682.     function ProcessBlur()
  2683.     {
  2684.         if (m_protectedState === 2)
  2685.             StopProtect();
  2686.         else if (m_protectedState === 1)   
  2687.             m_protectedState = 3;  
  2688.     }
  2689.     SetSettingsImpl(settings.vkMode, settings.skMode);
  2690.     ns.AddEventListener(window, 'unload', function ()
  2691.     {
  2692.         clearTimeout(m_protectChangeTimeout);
  2693.         clearTimeout(m_postponeStart);
  2694.         m_shutdown = true;
  2695.         m_observer.unbind();
  2696.     });
  2697.     var m_observer = new FocusChangeObserver(OnElementFocus, OnElementBlur, OnSettingsChanged);
  2698. };
  2699. function FocusChangeObserver(focusHandler, blurHandler, settingsChangedHandler)
  2700. {
  2701.     var m_targetPropertyName;
  2702.     if (document.addEventListener)
  2703.     {
  2704.         ns.AddEventListener(document, 'focus', onFocus, true);
  2705.         ns.AddEventListener(document, 'blur', onBlur, true);
  2706.         m_targetPropertyName = 'target';
  2707.     }
  2708.     else
  2709.     {
  2710.         ns.AddEventListener(document, 'focusin', onFocus);
  2711.         ns.AddEventListener(document, 'focusout', onBlur);
  2712.         m_targetPropertyName = 'srcElement';
  2713.     }
  2714.     var m_focusedElement = tryToGetFocusedInput();
  2715.     this.settingsChanged = function ()
  2716.     {
  2717.         if (m_focusedElement)
  2718.             settingsChangedHandler(m_focusedElement);
  2719.     }
  2720.     this.unbind = function ()
  2721.     {
  2722.         if (document.removeEventListener)
  2723.         {
  2724.             document.removeEventListener('focus', onFocus, true);
  2725.             document.removeEventListener('blur', onBlur, true);
  2726.         }
  2727.         else
  2728.         {
  2729.             document.detachEvent('onfocusin', onFocus);
  2730.             document.detachEvent('onfocusout', onBlur);
  2731.         }
  2732.         if (m_focusedElement)
  2733.         {
  2734.             blurHandler(m_focusedElement);
  2735.             m_focusedElement = null;
  2736.         }
  2737.     }
  2738.     if (m_focusedElement)
  2739.         focusHandler(m_focusedElement);
  2740.     function tryToGetActiveElement()
  2741.     {
  2742.         try
  2743.         {
  2744.             return document.activeElement;
  2745.         }
  2746.         catch (e)
  2747.         {}
  2748.         return null;
  2749.     }
  2750.     function tryToGetFocusedInput()
  2751.     {
  2752.         var element = tryToGetActiveElement();
  2753.         return (document.hasFocus() && isInputElement(element)) ? element : null;
  2754.     }
  2755.     function isInputElement(element)
  2756.     {
  2757.         return element &&
  2758.             element.tagName &&
  2759.             element.tagName.toLowerCase() === 'input';
  2760.     }
  2761.     function onBlur(event)
  2762.     {
  2763.         if (m_focusedElement)
  2764.         {
  2765.             var element = m_focusedElement;
  2766.             m_focusedElement = null;
  2767.             blurHandler(element);
  2768.         }
  2769.     }
  2770.     function onFocus(event)
  2771.     {
  2772.         var element = event[m_targetPropertyName];
  2773.         if (isInputElement(element))
  2774.         {
  2775.             m_focusedElement = element;
  2776.             focusHandler(element);
  2777.         }
  2778.     }
  2779. }
  2780. var instance = null;
  2781. ns.RunModule(function()
  2782. {
  2783.     try
  2784.     {
  2785.         if (!instance)
  2786.             instance = new VirtualKeyboard();
  2787.     }
  2788.     catch(e)
  2789.     {
  2790.         session.Log("VirtualKeyboard exception: " + (e.message || e));
  2791.     }
  2792. }, 2000);
  2793. });
  2794.  
  2795. })();
Advertisement
Add Comment
Please, Sign In to add comment