Monday, June 30, 2008

OmniMents

I absolutlely love Google Reader. It brings all of my favorite web pages, blogs, news sources, and comics to one central site. The only complaint I have is that it doesn't have a built-in comments section. I know that you can share things with a note... but notes suck. You can't reply, unless you make another note... and it is hard for people to follow the conversation.

I did quick search on Google to see if anyone else had had this problem and did something about it. I found a few people who agree with me, but no one has made a solution. So I decided to give it a try.

Introducing OmniMents!(name subject to change)

This is a very early version of a Google Reader Commenting System. And I mean early. This is basically a proof of concept, but I am a strong believer of release early, release often. So I am releasing at the earliest possible moment and I will try to add at least one feature a week. (We will see how long that last.)

Installing OmniMents:
  1. First you need firefox: www.getfirefox.com
  2. Then you need GreaseMonkey: https://addons.mozilla.org/en-US/firefox/addon/748
  3. Once GreaseMonkey is installed, restart firefox. Then right click on the little monkey on the bottom right hand corner. Go to "New User Script." You should see something like this:
  4. Make sure the includes is: "http://www.google.com/reader/view/*"
  5. Once you choose your favorite text editor then copy this into the script:
    // ==UserScript==
    // @name Google Reader OmniMents Link
    // @description Adds a OmniMent to the end of the action row
    // @namespace http://omniments.appspot.com
    // @include http://www.google.tld/reader/*
    // @include https://www.google.tld/reader/*
    // ==/UserScript==

    var entries=document.getElementById("entries");
    if(entries)
    entries.addEventListener('DOMNodeInserted', function(event){nodeInserted(event);},true);

    function nodeInserted(event){
    if (event.target.tagName=="DIV"){
    if (event.target.className === "entry-actions"){
    // List mode
    var linkbar=event.target;
    } else if (event.target.firstChild && event.target.firstChild.className=="card"){
    // Expanded mode
    var linkbar=event.target.firstChild.firstChild.childNodes[2].childNodes[1].firstChild;
    } else
    return;

    var parent= linkbar;
    while (parent.tagName != "TBODY") {
    parent= parent.parentNode;
    }

    var link = parent.getElementsByClassName("entry-title-link")[0].getAttribute('href');
    var site = parent.getElementsByClassName("entry-source-title-parent")[0].getElementsByTagName("A")[0].firstChild.nodeValue;
    var title = parent.getElementsByClassName("entry-title-link")[0].firstChild.nodeValue;

    link = "http://omniments.appspot.com/display.html?article=" + link
    var span = document.createElement("span");
    span.className = "OmniMents";
    var a_link = document.createElement("a");
    a_link.href = link;
    a_link.title = "OmniMents For: " + title;
    a_link.setAttribute('style','text-decoration:none;padding-right:10px;margin-right:10px; background: center right no-repeat;');
    a_link.appendChild(document.createTextNode("OmniMents"));
    span.appendChild(a_link);
    linkbar.appendChild(span);
    }
    }
  6. Then go to Google Reader and OmniMents should be in your action bar:

Clicking on the OmniMents link will take you to a comments page just for that URL. It should make you login the first time you try to post a comment. (It throws an error after logging in, but if you hit back twice it should all be good from there. I will fix the error tonight!)

Let me know any features you want added and any problems you have in the comments!

Thanks!