Google Reader Fluid Userscript
Here’s the result of tinkering with a Google Reader Userscript for Fluid for about 10 minutes… Can somebody please make this better, and post a link to your version in the comments?
Still working on getting a public repository for Fluid Userscripts. Can anyone donate Subversion hosting? :0]
// ==UserScript==
// @name Google Reader
// @namespace http://fluidapp.com
// @description Reader features for Fluid
// @include http://google.com/reader/*
// @include http://*.google.com/reader/*
// @author Todd Ditchendorf
// ==/UserScript==
(function() {
if (!window.fluid) {
return;
}
function updateDockBadge() {
var badgeString = "";
var title = document.title;
if (title && title.length) {
var start = title.indexOf("(");
var end = title.indexOf(")");
if (start > -1 && end > -1) {
start++;
badgeString = title.substring(start, end);
if (badgeString == "0") {
badgeString = "";
}
}
}
window.fluid.setDockBadge(badgeString);
}
setInterval(function(){updateDockBadge();}, 3000);
})();
March 3rd, 2008 at 08:09 am
Added Growl notifications:
http://pastie.org/160534
March 3rd, 2008 at 09:33 am
What about this?
(function() {
if (!window.fluid) {
return;
}
function updateDockBadge() {
var title = document.title || ”, match = title.match(/^.*\((\d+)\).*$/);
window.fluid.setDockBadge((match && match[1]) || ”);
}
setInterval(updateDockBadge, 3000);
})();
March 3rd, 2008 at 09:36 am
Also added a ‘Refresh’ dock menu action:
http://pastie.org/160534
March 3rd, 2008 at 10:21 am
Also, I’m still seeing a bug with Growl Notifications: the icon for the last-launched Fluid instance is used instead of the icon of the instance sending the notification.
March 4th, 2008 at 05:26 am
Jesse, ta a lot for the script, it fixes one of my Google Reader quibbles… now, if user scripts in Fluid could be sticky :).
I can confirm your observation on Growl notifications. Fluid’s registering of growl notifications seems to be a bit hit and miss ; besides the SSBs, there’s usually a « FluidInstance.app » also registered, and icons of SSBs seem to be assigned somewhat helter skelter (FluidInstance always seems to have the icon of one SSB, not necessarily the last one used, and the others might have an icon, though usually not all of them). I’d have said this is cosmetic, but it gets irritating now that you actually implement Growl notifications. Todd, help, please pretty please ?
March 4th, 2008 at 07:33 am
Wow, I also wrote some simple script for my own use, but here’s also the scripts!
Here’s my code(though it’s much simple and may not be useful at all).
// Google Reader Indicator for Fluid
// Version 0.1
// Last update: 3rd March, 2008
// Copyright (c) Byungho Min
// ==UserScript==
// @name Google Reader Indicator
// @description Display the number of unread items
// @include http*://www.google.com/reader/*
// @include http*://reader.google.com/*
// ==/UserScript==
setTimeout(getCount, 1000);
function getCount()
{
if (!window.fluid) {
return;
}
var tmp=document.title;
var tmp2=tmp.lastIndexOf(”(”);
var tmp3=tmp.lastIndexOf(”)”);
tmp=tmp.substr(tmp2+1,tmp3-tmp2-1);
window.fluid.setDockBadge(tmp);
setTimeout(getCount, 1000);
}
March 4th, 2008 at 07:59 am
I update a little (Reload dock menu added & a little more efficient).
// Google Reader Indicator for Fluid
// Version 0.1
// Last update: 3rd March, 2008
// Copyright (c) Byungho Min
// ==UserScript==
// @name Google Reader Indicator
// @namespace http://fluidapp.com
// @description Display the number of unread items
// @include http*://www.google.com/reader/*
// @include http*://reader.google.com/*
// @author Byungho Min
// ==/UserScript==
if (!window.fluid) {
return;
}
window.fluid.addDockMenuItem(”Refresh”, readerRefresh);
setTimeout(getCount, 1000);
function getCount()
{
var tmp=document.title;
var tmp2=tmp.lastIndexOf(”(”);
var tmp3=tmp.lastIndexOf(”)”);
tmp=tmp.substr(tmp2+1,tmp3-tmp2-1);
window.fluid.setDockBadge(tmp);
setTimeout(getCount, 1000);
}
function readerRefresh()
{
window.location.reload();
}
March 4th, 2008 at 11:54 am
@Jesse That’s HOT! nice work. I’ll look into the Growl Notification bug and the Userscript menu bug and get an update soon. thanks guys!
March 19th, 2008 at 17:00 pm
the pressing of “v” to open an item results in an extra google reader item being opened.