events occur window.detachEvent('onscroll', fn); window.attachEvent('onscroll', fn); doc.detachEvent('onkeydown', fn); doc.attachEvent('onkeydown', fn); // only start monitor on top doc searchshield.avgPageMonitor.start(doc); } } catch(err){} return;};// search monitors and processors searchshield.avgPageMonitor = { start: function(doc){ searchshield.avgSearchMonitor.stop(); searchshield.avgPageMonitor.stop(); searchshield.avgPageMonitor.process(doc); if (!searchshield.avgSearchMonitor.timeoutID) searchshield.avgPageMonitor.timeoutID = window.setTimeout(function(){searchshield.avgPageMonitor.start(doc)}, 1000); }, process: function(doc){ searchshield.avgProcessSearch(doc); }, stop: function(){ if (searchshield.avgPageMonitor.timeoutID) { window.clearTimeout(searchshield.avgPageMonitor.timeoutID); delete searchshield.avgPageMonitor.timeoutID; } }};searchshield.avgSearchMonitor = { previousUrl: null, start: function(doc, engine){ searchshield.avgPageMonitor.stop(); searchshield.avgSearchMonitor.stop(); searchshield.avgSearchMonitor.process(doc, engine); if (!searchshield.avgPageMonitor.timeoutID) searchshield.avgSearchMonitor.timeoutID = window.setTimeout(function(){searchshield.avgSearchMonitor.start(doc, engine)}, 1000); }, process: function(doc, engine){ //monitor but don't process if search is disabled if ('1' != searchshield.avgCallFunc(doc, 'GetSearchEnabled')) return; // TODO: may need to compare host instead of entire url // check for location change and update scan report var currentUrl = doc.location.href; if (searchshield.avgSearchMonitor.previousUrl != currentUrl) { //report scan result searchshield.avgSearchMonitor.previousUrl = currentUrl; avgreport.scanResult(doc, currentUrl); } engine.search.links = []; var links = searchshield.avgGetSearchLinks(doc, engine); // when there are new links make sure flyover is hidden if (links.length > 0) avglsflyover.hide(null, 1); var phishLinks = []; for (var i=0; i < links.length; i++) { var isPhishing = searchshield.avglsCheckandUpdate(links[i], engine); if (!!isPhishing) { phishLinks.push(links[i]); } } if (phishLinks.length > 0) { var prev = '1'; if ( engine.type == 'inline' ) prev = '0'; searchshield.avgCallFunc(doc, 'GetPhishingResults', prev); } else if (links.length > 0 && engine.type != 'inline') { searchshield.avgCallFunc(doc, 'FinalScanComplete'); } }, stop: function(){ if (searchshield.avgSearchMonitor.timeoutID) { window.clearTimeout(searchshield.avgSearchMonitor.timeoutID); delete searchshield.avgSearchMonitor.timeoutID; } }};searchshield.avgProcessSearch = function (doc){ // doc may be about:Tabs or about:Blank if (!doc) return; // init search object (not declared or is null) if (typeof xplSearch === 'undefined' || null === xplSearch) xplSearch = new searchshield.Search(); xplSearch.doc = doc; xplSearch.href = xplSearch.doc.location.href; xplSearch.uri = searchshield.parseLink(xplSearch.href); if (!searchshield.clockUrl) searchshield.clockUrl = searchshield.avgCallFunc(doc, 'GetIconUrl', '0'); xplSearch.clockUrl = searchshield.clockUrl if (!xplSearch.engines) { var aEng = xplSearch.getSearchNames(); var aEngLen = aEng.length; for (var i=0; i < aEngLen; i++) { xplSearch.addEngine(new searchshield[aEng[i]+'SearchEngine'](xplSearch)); } } if (!xplSearch.engine) { var engLen = xplSearch.engines.length; for (var i = 0; i < engLen; i++) { if (xplSearch.engines[i].validSearch()) { xplSearch.engine = xplSearch.engines[i]; break; } } } if (!xplSearch.engine) return; // set verdict display config xplSearch.engine.setRatingsConfig(doc); // init the alert popup searchshield.initPopupAlert(doc); // start search monitor searchshield.avgSearchMonitor.start(doc, xplSearch.engine); // attach click handlers for popup alerts doc.body.detachEvent("onclick", searchshield.blockClick); doc.body.attachEvent("onclick", searchshield.blockClick); doc.body.detachEvent("ondblclick", searchshield.blockClick); doc.body.attachEvent("ondblclick", searchshield.blockClick);};searchshield.avgGetSearchLinks = function (doc, engine){ if (!engine) { // restart page monitor searchshield.avgPageMonitor.start(doc); return; } var alltags = doc.getElementsByTagName('*'); for (var i = 0; i < alltags.length; i++) { if (alltags[i].getAttribute('avglschecked')) continue; // ignore linked resources if ((alltags[i].tagName) && (alltags[i].tagName == 'LINK')) continue; // ignore in-page bookmarks and javascript if ((!alltags[i].href) || (alltags[i].href.charAt(0) == '#') || // in-page bookmark (alltags[i].href.indexOf("javascript") == 0)) continue; // ignore verdicts if (alltags[i].id && (alltags[i].id.indexOf("XPLSS_") != -1)) continue; // ignore flyover anchors if (alltags[i].href && (alltags[i].href.indexOf("linkscanner:") == 0 || alltags[i].href.indexOf("avgthreatlabs.com") != -1)) continue; var href = engine.includeLink(alltags[i]); if (!href) continue; var newNode = engine.search.addLink(alltags[i], href); engine.addImage(newNode, engine.search.clockUrl, false); } // recursivesly process all frames var docFrames = doc.frames; if (docFrames && engine.processFrames) { for (var j = 0; j < docFrames.length; j++) { var attr; var frameDoc; try { attr = docFrames[j].frameElement.className; frameDoc = docFrames[j].document; } catch(err){} //TODO: make frame processing an engine function or