Skip to content

Instantly share code, notes, and snippets.

@justan
Last active December 11, 2015 22:58
Show Gist options
  • Save justan/4673255 to your computer and use it in GitHub Desktop.
Save justan/4673255 to your computer and use it in GitHub Desktop.
Add a google reader item to favorite when star it.
// ==UserScript==
// @name favorite item
// @namespace http://gmscrobber.whosemind.net
// @include https://www.google.com/reader/view/*
// @version 0.0.1
// ==/UserScript==
document.body.addEventListener('click', function(e) {
var target = e.target
, container
, title, url
;
if(hasClass(target, 'star') && !hasClass(target, 'item-star')){//click the star
container = target.parentNode.parentNode.lastChild;
title = container.lastChild.firstChild.innerHTML;
url = container.firstChild.href
if(sidebar){//firefox
sidebar.addPanel(title, url, '')
}
}
});
var rclass = /[\t\r\n]/g;
function hasClass(element, className) {
return (' ' + element.className.replace(rclass, ' ') + ' ').indexOf(' ' + className + ' ') >= 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment