Created
March 21, 2010 02:19
-
-
Save saitamanodoruji/339032 to your computer and use it in GitHub Desktop.
2ch+Tombloo
This file contains 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 2ch + Tombloo | |
// @namespace http://saitamanodoruji.tumblr.com/ | |
// @description register Quote - 2ch command by Tombloo | |
// @include http://*.2ch.net/test/read.cgi/* | |
// ==/UserScript== | |
// | |
// Command: Tombloo::Quote2ch | |
// | |
// | |
function boot(ev){ | |
if(ev) window.removeEventListener('GM_MinibufferLoaded', boot, false); | |
var tombloo = GM_Tombloo.Tombloo.Service; | |
var win = unsafeWindow; | |
var doc = document; | |
var Minibuffer = window.Minibuffer; | |
var $X = Minibuffer.$X; | |
Minibuffer.addCommand({ | |
name: 'Tombloo::Quote2ch', | |
command : function(stdin){ | |
stdin.forEach(function(node){ | |
var ctx = update({ | |
document : doc, | |
window : win, | |
selection : '' + win.getSelection(), | |
target : node, | |
event : {}, | |
title : null, | |
mouse : null, | |
menu : null, | |
}, win.location); | |
var ext = tombloo.check(ctx); | |
var ext2ch; | |
for (var i in ext) { | |
if(ext[i].name == 'Quote - 2ch') { | |
ext2ch = ext[i]; | |
} | |
} | |
if (!ext2ch) { | |
alert('2ch + Tombloo: ' | |
+ 'I cannot find the extractor \'Quote - 2ch\'. ' | |
+ 'Get http://gist.github.com/123087 and put it ' | |
+ 'in your tombloo/script folder.'); | |
} else { | |
tombloo.share(ctx, ext2ch, false); | |
Minibuffer.status('Tombloo::Quote2ch', 'Reblog', 100); | |
} | |
}); | |
return stdin; | |
} | |
}); | |
Minibuffer.addShortcutkey({ | |
key: 'Q', | |
description: 'Tombloo::Quote2ch', | |
command : function(){ | |
try { var stdin = Minibuffer.execute('pinned-or-current-node') }catch(e) {} | |
Minibuffer.execute('Tombloo::Quote2ch|clear-pin',stdin); | |
} | |
}); | |
function update(t, s){ | |
for(var p in s) | |
t[p] = s[p]; | |
return t; | |
} | |
} | |
if(window.Minibuffer){ | |
boot(); | |
} else { | |
window.addEventListener('GM_MinibufferLoaded', boot, false); | |
} |
This file contains 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment