Last active
December 11, 2015 22:58
-
-
Save justan/4673255 to your computer and use it in GitHub Desktop.
Add a google reader item to favorite when star it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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