Created
July 29, 2008 12:42
-
-
Save to/3075 to your computer and use it in GitHub Desktop.
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 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(<><![CDATA[ | |
.TMBL_posted, | |
.TMBL_posted a{ | |
color : silver !important; | |
} | |
.TMBL_posted .item_body a{ | |
color : dimgray !important; | |
} | |
.TMBL_posted img{ | |
-moz-opacity: 0.5; | |
} | |
]]></>); | |
var win = unsafeWindow; | |
var doc = win.document; | |
window.addEventListener('load', function(){ | |
win.Keybind.add('T', share); | |
}, true); | |
function share(event){ | |
var dump = []; | |
var tombloo = GM_Tombloo.Tombloo.Service; | |
var feed = win.get_active_feed(); | |
dump.push('--FEED_ID----'); | |
dump.push(feed.channel.link); | |
var item = win.get_active_item(true); | |
dump.push('--ITEM_ID----'); | |
dump.push(item.item_id); | |
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); | |
dump.push('--CTX_DOCUMENT----'); | |
dump.push(ctx.document); | |
dump.push('--CTX_WINDOW----'); | |
dump.push(ctx.window); | |
dump.push('--CTX_SELECTION----'); | |
dump.push(ctx.selection); | |
dump.push('--CTX_TARGET----'); | |
dump.push(ctx.target); | |
// FFFFOUND / Flickr / iza newsphoto | |
if([ | |
'flickr.com/', | |
'http://ffffound.com', | |
'http://www.bighappyfunhouse.com', | |
'http://f.hatena.ne.jp', | |
'http://lpcoverlover.com', | |
'http://www.chicksnbreasts.com', | |
'1eb46a2f1f83c340eee10cd49c144625'].some(function(pattern){ | |
return feed.channel.link.indexOf(pattern) != -1; | |
})){ | |
ctx.onImage = true; | |
ctx.target = $x('.//img[1]', body); | |
} | |
var ext = tombloo.check(ctx)[0]; | |
dump.push('--EXT_NAME----'); | |
dump.push(ext.name); | |
tombloo.share(ctx, ext, ext.name.match(/^Link /)); | |
win.addClass(parent, 'TMBL_posted'); | |
prompt('dump', dump.join('|||')); | |
} | |
// ---- [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; | |
} |
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
--FEED_ID---- | |
http://b.hatena.ne.jp/hotentry?&cname=elec | |
--ITEM_ID---- | |
3134039 | |
--CTX_DOCUMENT---- | |
[object HTMLDocument] | |
--CTX_WINDOW---- | |
[object Window] | |
--CTX_SELECTION---- | |
--CTX_TARGET---- | |
[object HTMLHeadingElement] | |
--EXT_NAME---- | |
Link - LDR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment