94 Part II — Getting Inside Gmail
Listing 6-1(continued)
// @include http://gmail.google.com/*
// @include http://mail.google.com/*
// @include https://mail.google.com/*
// @include http://gmail.google.com/gmail?logout&hl=en
// @include
https://www.google.com/accounts/ServiceLogin?service=mail*
// @exclude
// @description Displays a box in Gmail with your Bloglines
feeds
// ==/UserScript==
(function(){
var __items={};
function cache_gotsubs(e){
GM_setValue(‘subs’,e[‘responseText’]);
GM_setValue(‘subs_updated’,Date.parse(Date())/1000)
//GM_log/gci(‘getting data, subs_updated set to
‘+GM_getValue(‘subs_updated’,0));
gotsubs(e);
}
function getcachedsubs(){
var v=GM_getValue(‘subs’,null);
if (v){
updated=GM_getValue(‘subs_updated’,0);
d=Date.parse(Date())/1000;
if ((d - updated) > 300){
//GM_log/gci(‘cache expired: ‘+(d -
updated)+”(“+d+” - “+updated+”)”);
return false;
}else{
return v;
}
}
return false;
}
function getsubs(){
v=getcachedsubs();
if (v){
gotsubs(v);
return true;
}
getsubs();
}
function _getsubs(){
GM_xmlhttpRequest({‘method’:’GET’,’url’:”http://rpc.bloglines.
com/listsubs”,’onload’:cache_gotsubs});