Forked from Constellation/dashboard_plus_tombloo.user.js
Created
October 7, 2009 05:15
-
-
Save taizooo/203782 to your computer and use it in GitHub Desktop.
https://gist.github.com/5004/5e49293c18fb0768456e5ccbf3f1c51a6db8e3be and https://gist.github.com/198856/bf993a1a9646eb1ba94d1cb77f469beb63f570b9 via http://utatane.tumblr.com/post/201650622/manual-mode-dashboard-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 Dashboard + Tombloo | |
// @namespace http://d.hatena.ne.jp/Constellation/ | |
// @description register reblog command by Tombloo | |
// @include http://www.tumblr.com/dashboard* | |
// @include http://www.tumblr.com/show* | |
// @include http://www.tumblr.com/iphone* | |
// ==/UserScript== | |
// | |
// Detail : Pinned-node Reblog | |
// Pinned-node Local Download | |
// | |
// Command: Tombloo::Reblog | |
// Tombloo::Local | |
// | |
// | |
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; | |
[ | |
// Tombloo Reblog | |
{ | |
name : 'Tombloo::Reblog', | |
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)[0]; | |
tombloo.share(ctx, ext, !!~this.args.indexOf("-m")); | |
Minibuffer.status('Tombloo::Reblog'+node.id,'Reblog',100); | |
}, this); | |
return stdin; | |
} | |
}, | |
// Tombloo Local Download for Photo Post | |
{ | |
name : 'Tombloo::Local', | |
command : function(stdin){ | |
stdin.forEach(function(node){ | |
var target = $X('descendant::img[contains(concat(" ", normalize-space(@class), " "), " image ") or contains(concat(" ", normalize-space(@class), " "), " photo ")]',node)[0] || null; | |
if (!target) return; | |
var ctx = update({ | |
document : doc, | |
window : win, | |
selection : '' + win.getSelection(), | |
target : target, | |
event : {}, | |
title : null, | |
mouse : null, | |
menu : null, | |
onImage : true, | |
}, win.location); | |
var ps = tombloo.extractors.Photo.extract(ctx); | |
ps = update({ | |
page : ctx.title, | |
pageUrl : ctx.href, | |
}, ps); | |
Minibuffer.status('Tombloo::Local'+node.id,'Download', 100); | |
GM_Tombloo.Local | |
.post(ps) | |
}); | |
return stdin; | |
} | |
}, | |
].forEach(Minibuffer.addCommand); | |
[ | |
{ | |
key : 't', | |
description : 'Reblog by Tombloo', | |
command : function(){ | |
try { var stdin = Minibuffer.execute('pinned-or-current-node') }catch(e) {} | |
Minibuffer.execute('Tombloo::Reblog|clear-pin',stdin); | |
} | |
}, | |
{ | |
key : 'T', | |
description : 'Manual Reblog by Tombloo', | |
command : function(){ | |
try { var stdin = Minibuffer.execute('pinned-or-current-node') }catch(e) {} | |
Minibuffer.execute('Tombloo::Reblog -m |clear-pin',stdin); | |
} | |
}, | |
{ | |
key : 'd', | |
description : 'Download by Tombloo', | |
command : function(){ | |
try { var stdin = Minibuffer.execute('pinned-or-current-node') }catch(e) {} | |
Minibuffer.execute('Tombloo::Local|clear-pin',stdin); | |
} | |
} | |
].forEach(Minibuffer.addShortcutkey); | |
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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment