g_arrCache={};g_arrCacheTm={};chrome.extension.onRequest.addListener(function(a,b,d){g_arrCache[b.tab.id]=a.timing;g_arrCache[b.tab.id].status_pagespeed_url=b.tab.url;d({})});chrome.tabs.onRemoved.addListener(function(a){delete g_arrCache[a];delete g_arrCacheTm[a]});document.addEventListener("DOMContentLoaded",function(){ClearLocalCache();CheckVersion()});chrome.tabs.onUpdated.addListener(function(a,b){"undefined"==typeof b.url||""==b.url||eOk(b.url)&&AjaxUpdateTab(b.url,a)});
chrome.tabs.onSelectionChanged.addListener(function(a){chrome.tabs.get(a,function(b){"undefined"==typeof b.url||""==b.url||eOk(b.url)&&AjaxUpdateTab(b.url,a)})});function GetLast(a){a="t"+a;return"undefined"==typeof localStorage[a]?{tm:0,url:""}:(a=localStorage[a].match(/([0-9,]+);(.*)/i))?{tm:a[1],url:a[2]}:{tm:0,url:""}}function SetLast(a,b){1E3<localStorage.length&&ClearLocalCache();var d=Date.parse(new Date)/1E3;localStorage["t"+a]=d+";"+b}
function ClearLocalCache(){if(0!=localStorage.length)for(var a,b=localStorage.length-1;0<=b;b--)a=localStorage.key(b),"t"==a.substr(0,1)&&localStorage.removeItem(a)}
function AjaxUpdateTab(a,b){var d=a.indexOf("#");-1!=d&&(a=a.substr(0,d));var d="http://toolbarqueries.google.com/tbr?client=navclient-auto&features=Rank&ch=6"+makehash(a)+"&q=info:"+a,c=new XMLHttpRequest,e=window.setTimeout(function(){c.abort()},2E4);try{c.onreadystatechange=function(){4==c.readyState&&(window.clearTimeout(e),OnGGTabEnd(a,b,200==c.status?c.responseText:""))},c.onerror=function(){window.clearTimeout(e)},c.open("GET",d,!0),c.send(null)}catch(f){window.clearTimeout(e)}}
function OnGGTabEnd(a,b,d){var c="?";if(""!=d&&(c=d.substr(9,2).replace(/\s$/,""),""==c||isNaN(1*c)))c="?";updatePR(c,a,b,!0)};
