Home IT companies Separating the grains from the chaff in Google Reader

Separating the grains from the chaff in Google Reader

by admin

Separating the grains from the chaff in Google Reader
At work, I try not to read Habr and other themed sites, they are too addictive.You can spend all day reading articles and never get anything done at work. But I do not want to miss something newand interesting either, so I subscribe to various RSS-channels. After work, and more often on weekends, I open Google Reader and look through the entire list of accumulated posts. Some of them are written on topics of interest to me, the rest are not. It reminds me of reading email, only incoming emails and spam end up in the same folder.
I put up with it at first, but this weekend, with the Greasemonkeyscript, I fixed the situation.
Separating the grains from the chaff in Google Reader
Google Reader has a newbutton : "Mark selected as read", and each article has a checkbox.
Now, when I look through the list of posts, I immediately mark the ones that don’t interest me and "read" them with one button. Only the ones that are worthy of further scrutiny remain.
If you like the idea, you can install Greasemonkey script. It requires Mozilla Firefox and the Greasemonkey
The disadvantages are that the script does not work in Google Chrome. The reason for this is browser error in the processing of the created KeyboardEvent.
Just in case I publish the source code of the script:

// ==UserScript==
// @name Google Reader - Mark selected items as read
// @namespace twitter.com/rodiontsev
// @description This script adds a button "Mark selected as read"and checkbox for each item.
// @include htt*://www.google.tld/reader/view/*
// ==/UserScript==
/*
History version
1.0 on 10/01/2009:
- Initial version.
*/
var buttonText = "Mark selected as read" ;
var buttonId = "mark-selected-as-read" ;
var articles = new Array();
document addEventListener( DOMNodeInserted" , function ( event ){nodeInserted( event );}, true );
function nodeInserted( event ) {
var entries = document getElementById( "entries" );
if (entries matchClass(entries, "list" )) {
var button = document getElementById(buttonId);
if (!button) {
articles = new Array();
appendButton();
}
var element = event target;
if (element. className element.className.match(/entry\s+entry-\d+/) != null ) {
articles.push(element);
var checkbox = document createElement( "input" );
checkbox.type = "checkbox" ;
checkbox.className = "mark-selected-as-read-checkbox-class" ;
checkbox.style.marginRight = "9px" ;
checkbox.style.verticalAlign = "top" ;
checkbox.addEventListener( "click" , function ( event ) { event stopPropagation();}, true );
var entrySecondary = element.getElementsByClassName( "entry-secondary" )[0];
entrySecondary.insertBefore(checkbox, entrySecondary.firstChild);
}
}
}
function appendButton() {
var viewerTopControlsId = "viewer-top-controls" ;
var markAllAsReadId = "mark-all-as-read-split-button" ;
var divVewerTopControls = document getElementById(viewerTopControlsId);
var btnMarkAllAsRead = document getElementById(markAllAsReadId);
if ((divVewerTopControls != null ) (btnMarkAllAsRead != null )) {
var button = document createElement( "div" );
button.className = "goog-button goog-button-base unselectable goog-inline-block goog-button-float-left goog-button-tight scour-disabled viewer-buttons" ;
button.id = buttonId;
button.innerHTML = "<div class=\"goog-button-base-outer-box goog-inline-block\"> "
+ "<div class=\"goog-button-base-inner-box goog-inline-block\"> "
+ "<div class=\"goog-button-base-pos\"> "
+ "<div class=\"goog-button-base-top-shadow\"> </div> "
+ "<div class=\"goog-button-base-content\"> "
+ "<div class=\"goog-button-body\"> " +buttonText + "</div> "
+ "</div> "
+ "</div> "
+ "</div> "
+ "</div> " ;
button.addEventListener( "click" , markSelectedAsRead, false );
divVewerTopControls.insertBefore(button, btnMarkAllAsRead);
}
}
function matchClass (element, sClassName) {
return (sClassName
element.className
element.className.length
element.className.match( new RegExp( "(^|\\s+)(" + sClassName + ")($|\\s+)" )));
}
function simulateClick(node) {
var event = node.ownerDocument.createEvent( "MouseEvents" );
event initMouseEvent( "click" , true , true , window, 1, 0, 0, 0, 0, false , false , false , false , 0, null );
node.dispatchEvent( event );
}
function simulateKeypress(node, keyCode) {
var event = node.ownerDocument.createEvent( "KeyboardEvent" );
event initKeyEvent( "keypress" , true , true , null , false , false , false , false , keyCode, 0);
node.dispatchEvent( event );
}
function simulateRead(node) {
simulateKeypress(node, 77); //"m" button - mark entry as read.
}
function simulateCollapse(node) {
simulateKeypress(node, 79); //"o" button - expand/collapse entry.
}
function getArticleIcon(article) {
var divs =article.getElementsByTagName( "div" );
for ( var i = 0;i <divs.length;i++) {
var div = divs[i];
if (matchClass(div, "entry-icons" )) return div;
}
return null ;
}
function markSelectedAsRead() {
var container = document getElementById( "entries" );
container.style.display = "none" ;
for ( var i = 0; i < articles.length; i++) {
var article = articles[i];
var checkbox = article.getElementsByTagName( "input" )[0];
if (checkbox. checked ) {
if (!(matchClass(article, "read" ))) {
var articleIcon = getArticleIcon(article);
simulateClick(articleIcon);
if (!(matchClass(article, "read" ))) {
simulateRead(articleIcon);
}
if (matchClass(article, "expanded" )) {
simulateCollapse(articleIcon);
}
}
checkbox. checked = false ;
}
}
container.style.display = "block" ;
}
* This source code was highlighted with Source Code Highlighter

You may also like