Tumblr dashboard bookmark
by
vzvu3k6k
2014-05-14 [2014/05/14 20:53:06]
Save your depth and restart digging
@@ -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 です。