Forks

  • gist: 203782 by taizooo https://gist.github.com/500... created Tue Oct 06 22:15:19 -0700 2009

Revisions

gist: 5004 Download_button fork
public
Description:
userscript : Dashboard + Tombloo
Public Clone URL: git://gist.github.com/5004.git
Embed All Files: show embed
dashboard_plus_tombloo.user.js #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// ==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, false);
          Minibuffer.status('Tombloo::Reblog'+node.id,'Reblog',100);
        });
        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 : '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);
}