Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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