Tumblr dashboard bookmark

    @@ -1,38 +1,41 @@ -/* - * @title Tumblr dashboard bookmark - * @description Save your depth and restart digging - * @include http://www.tumblr.com/* - * @license Public Domain - */ - (function(){ - var currentPosition = window.scrollY; - var currentPost; - var posts = document.querySelectorAll('#posts .post_container:not(.new_post_buttons_container):not(._bookmark)'); - for(var i = 0; i < posts.length; i++){ + let currentPosition = window.scrollY, + currentPost, + posts = document.querySelectorAll('#posts .post_container:not(.new_post_buttons_container):not(._bookmark)'); + for(let i = 0; i < posts.length; i++){ if(jQuery(posts[i]).offset().top >= currentPosition){ currentPost = posts[i]; break; } } - var id = (parseInt(currentPost.querySelector(".post").id.replace("post_", ""), 10) + 1), - href = window.next_page.replace(/\d+$/, id), - now = new Date, + // window.next_page + // in dashboard page + // * http://www.tumblr.com/dashboard/2/12345 // initial + // * /dashboard/2/12345 // after autopaging + // in search page + // * http://www.tumblr.com/tagged/bookmarklet?before=12345 // initial + // * /tagged/bookmarklet?before=12345 // after autopaging + // `before` param is not a post id. - // next_page - // * http://www.tumblr.com/dashboard/2/12345 // initial - // * /dashboard/2/12345 // after autopaging - // * http://www.tumblr.com/tagged/bookmarklet?before=12345 // initial - // * /tagged/bookmarklet?before=12345 // after autopaging + let now = new Date, label = window.next_page.replace("http://www.tumblr.com", "") - .replace(/\?before=\d+$|\d+\/\d+$/, "").slice(1) - + " - " + [now.getFullYear(), now.getMonth(), now.getDate()].join("-"), - insertHTML = + .replace(/\?before=\d+$|\/\d+\/\d+$/, "").slice(1) + + " - " + [now.getFullYear(), now.getMonth(), now.getDate()].join("-"); + + let href; + if(label.indexOf("dashboard") == 0){ + let postId = parseInt(currentPost.querySelector(".post").id.replace("post_", ""), 10) + 1; + href = window.next_page.replace(/\d+$/, postId); + }else{ + href = window.next_page; + } + + let insertHTML = '<li class="post_container _bookmark">' + ' <div class="post post_full">' + ' Bookmark: <a href="' + href + '">' + label + '</a>' + ' </div>' + '</li>'; jQuery(insertHTML).insertBefore(currentPost).hide().slideDown(); -})(); +})();
  • (function(){
        let currentPosition = window.scrollY,
            currentPost,
            posts = document.querySelectorAll('#posts .post_container:not(.new_post_buttons_container):not(._bookmark)');
        for(let i = 0; i < posts.length; i++){
            if(jQuery(posts[i]).offset().top >= currentPosition){
                currentPost = posts[i];
                break;
            }
        }
    
        // window.next_page
        //   in dashboard page
        //     * http://www.tumblr.com/dashboard/2/12345  // initial
        //     * /dashboard/2/12345                       // after autopaging
        //   in search page
        //     * http://www.tumblr.com/tagged/bookmarklet?before=12345  // initial
        //     * /tagged/bookmarklet?before=12345                       // after autopaging
        //     `before` param is not a post id.
    
        let now = new Date,
            label = window.next_page.replace("http://www.tumblr.com", "")
                .replace(/\?before=\d+$|\/\d+\/\d+$/, "").slice(1)
                + " - " + [now.getFullYear(), now.getMonth(), now.getDate()].join("-");
    
        let href;
        if(label.indexOf("dashboard") == 0){
            let postId = parseInt(currentPost.querySelector(".post").id.replace("post_", ""), 10) + 1;
            href = window.next_page.replace(/\d+$/, postId);
        }else{
            href = window.next_page;
        }
    
        let insertHTML = 
                '<li class="post_container _bookmark">' +
                '  <div class="post post_full">' +
                '    Bookmark: <a href="' + href + '">' + label + '</a>' +
                '  </div>' +
                '</li>';
        jQuery(insertHTML).insertBefore(currentPost).hide().slideDown();
    })();
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2014/05/14 20:53:06 - 2014-05-14
  2. 2014/05/14 20:43:26 - 2014-05-14
  3. 2013/06/09 14:33:59 - 2013-06-09
  4. 2013/06/09 14:29:17 - 2013-06-09
  5. 2013/06/09 14:18:52 - 2013-06-09
  6. 2013/06/09 11:58:16 - 2013-06-09