// ==UserScript== // @name LDR + Tombloo // @namespace http://userscripts.org/users/7010 // @updateURL http://userscripts.org/scripts/source/23537.user.js // @include http://reader.livedoor.com/reader/* // @include http://fastladder.com/reader/* // ==/UserScript== GM_addStyle(<>); var FEED_TYPE_DEFS = { photo : [ 'flickr.com/', 'http://ffffound.com', 'http://www.bighappyfunhouse.com', 'http://f.hatena.ne.jp', 'http://lpcoverlover.com', 'http://www.chicksnbreasts.com', 'http://www.muji.net/mt/naruhodo/newitem/', 'http://rephoto.orig.jp', 'http://website.com', 'http://pipes.yahoo.com/pipes/pipe.info?_id=mgUSCOVt3RGwC6XC073fcQ', 'http://pipes.yahoo.com/pipes/pipe.info?_id=vi_it4xr3RGaNl7FbLsjiw', 'http://pipes.yahoo.com/pipes/pipe.info?_id=1eb46a2f1f83c340eee10cd49c144625', 'http://pipes.yahoo.com/pipes/pipe.info?_id=842608e370e30856205cabaf9793ceb2', 'http://pipes.yahoo.com/pipes/pipe.info?_id=kIBpZMzP3RGrUGmm1ZzWFw', 'http://pipes.yahoo.com/pipes/pipe.info?_id=3OC7gKP23RGT2g7o3rVd_w', 'http://www.as-found.net/', 'http://www.whytheluckystiff.net/quiet/', 'http://www.fecalface.com/POTD/', ], quote : [], }; var win = unsafeWindow; var doc = win.document; window.addEventListener('load', function(){ win.Keybind.add('T', share); }, true); with(win){ ItemFormatter.TMPL.tmpl = ItemFormatter.TMPL.tmpl.replace(/(\[\[pinned\]\])/, '$1 [[TMBL_type]]') register_hook('BEFORE_PRINTFEED', function(feed) { var type = checkType(feed); if(!type) return; var cls = 'TMBL_' + type; feed.items.forEach(function(item){ item.TMBL_type = cls; }); }); } function share(event){ var tombloo = GM_Tombloo.Tombloo.Service; var feed = win.get_active_feed(); var item = win.get_active_item(true); var target = item.element; var parent = $x('ancestor::div[starts-with(@id, "item_count")]/parent::div', target); var body = $x('.//div[@class="item_body"]', parent); var ctx = update({ document : doc, window : win, selection : '' + win.getSelection(), target : target, event : {}, title : null, mouse : null, menu : null, }, win.location); if(checkType(feed, 'photo')){ ctx.onImage = true; ctx.target = $x('.//img[1]', body); } var ext = tombloo.check(ctx)[0]; tombloo.share(ctx, ext, ext.name.match(/^Link /)); win.addClass(parent, 'TMBL_posted'); } function checkType(feed, type){ var link = feed.channel.link; if(type){ if(FEED_TYPE_DEFS[type].some(function(def){return link.indexOf(def) != -1})) return type; } else { for(type in FEED_TYPE_DEFS) if(checkType(feed, type)) return type; } } // ---- [Utility] ---------------------------------------------------- function update(t, s){ for(var p in s) t[p] = s[p]; return t; } function $x(exp, context){ context = context || document; return document.evaluate(exp, context, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; }