Skip to content

Instantly share code, notes, and snippets.

@serian
Last active December 27, 2015 21:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save serian/7394553 to your computer and use it in GitHub Desktop.
Save serian/7394553 to your computer and use it in GitHub Desktop.
tombfix, tombloo, InoReader, Firefox
Tombfix.Service.extractors.register([
{
name : 'IR',
getItem : function(ctx, getOnly){
if(ctx.host != 'inoreader.com')
return;
var item = $x('ancestor-or-self::div[@class = "article_full_contents"]', ctx.target);
if(!item)
return;
var channel = $x('//div[@class="view_toolbar_inner"]/a[@class="bluelink underlink"]') || $x('../div[@class="article_header"]/div[@class="article_header_text"]/div[@class="article_feed_title"]',item) || '';
var res = {
author : ($x('div[@class="article_title"]/*[@class="article_author"]/text()', item) || '').extract(/by (.*)/),
title : $x('div[@class="article_title"]/a/text()', item) || '',
feed : channel.textContent,
href : $x('(div[@class="article_title"]/a)[1]/@href', item).replace(/[?&;](fr?(om)?|track|ref|FM)=(r(ss(all)?|df)|atom)([&;].*)?/,'') || channel.href
};
var uri = createURI(res.href);
if(!getOnly){
ctx.title = res.feed + (res.title? ' - ' + res.title : '');
ctx.href = res.href;
ctx.host = uri.host;
}
return res;
}
},
{
name : 'Link - IR',
ICON : 'https://inoreader.com/favicon.ico',
check : function(ctx){
return Extractors.IR.getItem(ctx, true);
},
extract : function(ctx){
Extractors.IR.getItem(ctx);
return Extractors.Link.extract(ctx);
}
},
{
name : 'Quote - IR',
ICON : 'https://inoreader.com/favicon.ico',
check : function(ctx){
return Extractors.IR.getItem(ctx, true) && ctx.selection;
},
extract : function(ctx){
Extractors.IR.getItem(ctx);
return Extractors.Quote.extract(ctx);
}
},
{
name : 'Photo - IR',
ICON : 'https://inoreader.com/favicon.ico',
check : function(ctx){
return Extractors.IR.getItem(ctx, true) &&
ctx.onImage;
},
extract : function(ctx){
Extractors.IR.getItem(ctx);
return Extractors.check(ctx)[0].extract(ctx);
}
}
],'Link');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment