var page={isWidthScroll:false,isHeightScroll:false,windowWidth:0,windowHeight:0,documentWidth:0,documentHeight:0,currentX:0,currentY:0,scrollBarWidth:16,iframe:null,setVars:function(){page.isWidthScroll=page.checkWidthScroll();page.isHeightScroll=page.checkHeightScroll();page.windowWidth=window.innerWidth+(page.isWidthScroll?-16:0);page.documentWidth=document.width;page.documentHeight=document.height;page.windowHeight=window.innerHeight+(page.isHeightScroll?-16:0);page.currentX=0;page.currentY=0;if(document.location.hostname=="mail.google.com"){page.iframe=document.getElementById("canvas_frame");page.windowHeight=page.iframe.clientHeight;page.windowWidth=page.iframe.contentDocument.width;page.documentHeight=page.iframe.contentDocument.height;page.documentWidth=page.iframe.contentDocument.width}},scrollToCurrent:function(){if(document.location.hostname=="mail.google.com"){page.iframe.contentDocument.body.scrollTop=page.currentY;page.iframe.contentDocument.body.scrollLeft=page.currentX}else{document.body.scrollTop=page.currentY;document.body.scrollLeft=page.currentX}},computeNextScreen:function(){if(page.currentX+page.windowWidth-16<page.documentWidth){page.currentX+=page.windowWidth-16;return true}else{page.currentX=0;if(page.currentY+page.windowHeight-16>=page.documentHeight){return false}else{page.currentY+=page.windowHeight-16;return true}}},checkWidthScroll:function(){return(document.body.clientWidth<document.body.scrollWidth)},checkHeightScroll:function(){return(document.body.clientHeight<document.body.scrollHeight)},fixedElements_:[],enableFixedPosition:function(g){if(g){for(var d=0,a=this.fixedElements_.length;d<a;++d){this.fixedElements_[d].style.position="fixed"}}else{this.fixedElements_=[];var f=document.createNodeIterator(document.documentElement,NodeFilter.SHOW_ELEMENT,null,false);var c;while(c=f.nextNode()){var b=document.defaultView.getComputedStyle(c,"");if(!b){return}var h=b.getPropertyValue("position");if(h=="fixed"){this.fixedElements_.push(c);c.style.position="absolute"}}}},checkPageIsOnlyEmbedElement:function(){var d=document.body.children;var a=false;for(var c=0;c<d.length;c++){var b=d[c].tagName;if(b=="OBJECT"||b=="EMBED"||b=="VIDEO"||b=="SCRIPT"){a=true}else{if(d[c].style.display!="none"){a=false;break}}}return a},onRequest:function(f,b,d){console.log(f);if(f.type=="takeCapture"){var a={};if(f.start){page.setVars();page.enableFixedPosition(false);try{document.getElementById("presence").style.display="none";window.setTimeout("document.getElementById('presence').style.display=''",10000)}catch(c){}try{document.getElementById("navi-bar").style.display="none";window.setTimeout("document.getElementById('navi-bar').style.display=''",10000)}catch(c){}}page.scrollToCurrent();if(page.iframe){a.top=page.iframe.contentDocument.body.scrollTop;a.left=page.iframe.contentDocument.body.scrollLeft}else{a.top=document.body.scrollTop;a.left=document.body.scrollLeft}a.finish=!page.computeNextScreen();if(a.finish){a.width=page.documentWidth;a.height=page.documentHeight;a.url=document.location.toString()}d(a)}if(f.type=="finish"){page.enableFixedPosition(true);page.currentX=0;page.currentY=0;page.scrollToCurrent()}}};try{chrome.extension.onRequest.removeListener(page.onRequest)}catch(e){}try{chrome.extension.onRequest.addListener(page.onRequest)}catch(e){};