Tumblr: 連続ポストを読み飛ばす

  • /*
     * @title Tumblr: 連続ポストを読み飛ばす
     * @description ダッシュボードで表示しているポストと異なるtumblelogまたは種類(text, quote, photoなど)が違うポストまでスクロールするブックマークレット
     * @include https://www.tumblr.com/dashboard*
     * @license CC0
     */
    
    // https://secure.assets.tumblr.com/assets/scripts/dashboard.jsの
    // /*! scripts/application/keycommands.js */以下で定義されている
    // Tumblr.KeyCommands.keydownのコードを参考にした。
    
    (function(){
      this.update_post_positions();
      this.current_position = jQuery(document).scrollTop() + 7;
    
      var current_post;
      for (var i in this.post_positions){
        var p = this.post_positions[i];
        if(this.check_offset(p)){
          current_post = jQuery('#' + i);
          break;
        }
      }
    
      var skip_num = 0;
      var next_container = _.chain(current_post.closest('.post_container').nextAll('.post_container'))
            .find(function(container){
              skip_num++;
              container = jQuery(container);
              var post = container.find('.post');
              return (current_post.data('tumblelog-name') != post.data('tumblelog-name')
                      || current_post.data('type') != post.data('type'))
                && container.is(':visible'); // ユーザースクリプトなどで隠されたポストは弾く
            }).value();
    
      if(next_container.length == 0){
        this.go_to_position = jQuery(document).height();
      }else{
        // ghostlistによって.post_containerの子要素が一時的に削除されている場合には
        // post_positionsに登録されていないので、スクロール位置を独自に計算する
        this.go_to_position = jQuery(next_container).offset().top;
      }
      this.animating = true;
      jQuery("html,body").stop().animate({
        scrollTop: this.go_to_position - this.scroll_offset
      }, this.scroll_speed * skip_num, (function(){
        this.animating = false;
      }).bind(this));
    }).bind(Tumblr.KeyCommands)();
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2014/05/10 00:20:03 - 2014-05-10
  2. 2014/05/09 23:05:21 - 2014-05-09