Skip to content

Instantly share code, notes, and snippets.

@saitamanodoruji
Created April 15, 2011 14:48
Show Gist options
  • Save saitamanodoruji/921812 to your computer and use it in GitHub Desktop.
Save saitamanodoruji/921812 to your computer and use it in GitHub Desktop.
Staccfeed + Tombloo
// ==UserScript==
// @name Staccfeed + Tombloo
// @namespace http://saitamanodoruji.tumblr.com/
// @description register Photo - pixiv (with *Tags) command by Tombloo on Staccfeed
// @include http://www.pixiv.net/stacc/*
// @version 0.1.1.20110416
// ==/UserScript==
//
// Command: Tombloo::Staccfeed
//
// dependent on tombloo.service.pixiv.js by polygon-planet
// https://github.com/polygonplanet/tombloo/blob/master/tombloo.service.pixiv.js
// http://polygon-planet.blogspot.com/2011/04/pixivposttombloo.html
//
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;
var D = Minibuffer.D;
Minibuffer.addCommand({
name: 'Tombloo::Staccfeed',
command : function(stdin){
with(D()){
var id = new Date().getDate();
loop(stdin.length, function(i) {
if($X('.//div[contains(concat(" ", @class, " "), " post-img ")]/a[1]/img[1]', stdin[i])[0]) {
var ctx = update({
document : doc,
window : win,
target : $X('.//div[contains(concat(" ", @class, " "), " post-img ")]/a[1]/img[1]', stdin[i])[0],
onImage : true,
onLink : true,
link : $X('.//div[contains(concat(" ", @class, " "), " post-img ")]/a[1]', stdin[i])[0].href,
inFrame : false,
hasBGImage : true,
}, win.location);
tombloo.share(ctx, tombloo.extractors['Photo - pixiv (with *Tags)'], false);
}
if ( !i == stdin.length -1 ) {
Minibuffer.status('Tombloo::Staccfeed' + id, 'Reblog'+ ' (' + eval(i + 1) + '/' + stdin.length + ')');
} else {
Minibuffer.status('Tombloo::Staccfeed' + id, 'Reblog'+ ' (' + eval(i + 1) + '/' + stdin.length + ') ... done', 100);
}
return wait(5);
});
}
return stdin;
}
});
Minibuffer.addShortcutkey({
key: 'U',
description: 'Tombloo::Staccfeed',
command : function(){
try { var stdin = Minibuffer.execute('pinned-or-current-node') }catch(e) {}
Minibuffer.execute('Tombloo::Staccfeed|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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment