Tumblr dashboard bookmark
by
vzvu3k6k
2014-05-14 [2014/05/14 20:53:06]
Save your depth and restart digging
@@ -6,43 +6,35 @@
*/
(function(){
- var currentPosition = window.scrollY,
- currentPost,
- posts = document.querySelectorAll('#posts .post_container:not(.new_post_buttons_container):not(._bookmark)');
- for(var 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.
- // 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.
+ var currentPost = Tumblr.KeyCommands.current_post;
- var 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("-");
+ var 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("-");
- var href;
- if(label.indexOf("dashboard") == 0){
- var postId = parseInt(currentPost.querySelector(".post").id.replace("post_", ""), 10) + 1;
- href = window.next_page.replace(/\d+$/, postId);
- }else{
- href = window.next_page;
- }
+ var href;
+ if(label.indexOf("dashboard") == 0){
+ var postId = parseInt(currentPost.data("post-id"), 10) + 1;
+ href = window.next_page.replace(/\d+$/, postId);
+ }else{
+ href = window.next_page;
+ }
- var 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();
-})();
+ var insertHTML =
+ '<li class="post_container _bookmark">' +
+ ' <div class="post post_full" style="padding: 20px">' +
+ ' Bookmark: <a href="' + href + '">' + label + '</a>' +
+ ' </div>' +
+ '</li>';
+ jQuery(insertHTML).insertBefore(currentPost.parent().next()).hide().slideDown();
+})();
/*
* @title Tumblr dashboard bookmark
* @description Save your depth and restart digging
* @include http://www.tumblr.com/*
* @license Public Domain
*/
(function(){
// 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.
var currentPost = Tumblr.KeyCommands.current_post;
var 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("-");
var href;
if(label.indexOf("dashboard") == 0){
var postId = parseInt(currentPost.data("post-id"), 10) + 1;
href = window.next_page.replace(/\d+$/, postId);
}else{
href = window.next_page;
}
var insertHTML =
'<li class="post_container _bookmark">' +
' <div class="post post_full" style="padding: 20px">' +
' Bookmark: <a href="' + href + '">' + label + '</a>' +
' </div>' +
'</li>';
jQuery(insertHTML).insertBefore(currentPost.parent().next()).hide().slideDown();
})();
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。