Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save saitamanodoruji/952876 to your computer and use it in GitHub Desktop.
Save saitamanodoruji/952876 to your computer and use it in GitHub Desktop.
Continue from the Post Reblogged
// ==UserScript==
// @name Continue from the Post Reblogged
// @namespace http://saitamanodoruji.tumblr.com/
// @description Press "Shift + B", and Back to the Dashboard where the reblogged-post on the current-node is from.
// @include http://www.tumblr.com/dashboard*
// @include http://www.tumblr.com/show/*
// @include http://www.tumblr.com/blog/*
// @include http://www.tumblr.com/likes*
// @include https://www.tumblr.com/dashboard*
// @include https://www.tumblr.com/show/*
// @include https://www.tumblr.com/blog/*
// @include https://www.tumblr.com/likes*
// @version 0.1.10
// @update 2016-03-26
// ==/UserScript==
//
// This script is dependent on
// -Minibuffer http://userscripts.org/scripts/show/11759
// -LDRize http://userscripts.org/scripts/show/11562
//
// is_reblog なポストの左上に出る You reblogged someone の
// someone のリンクから post id を取って、そこから Dashboard に潜る。
//
// つまり、「今夜はこれ以上潜れない、これが Last Reblog だ」となった場合に、
// 翌朝 http://www.tumblr.com/tumblelog/{yourID} を開いて
// その Last Reblog のところで Shift + B を押せば、
// 昨晩の続きが新しいタブで開くので、そこからまた潜ることができる。
(function() {
const KEY_TO_OPEN ='B';
var boot = function(ev) {
if (ev) window.removeEventListener('GM_MinibufferLoaded', boot, false);
with (sharedObject.Minibuffer) {
addShortcutkey({
key: KEY_TO_OPEN,
description: 'continueFromThePostReblogged',
command: function() {
try {
execute( 'continueFromThePostReblogged', execute('current-node'));
} catch (e) { console.log(e); GM_log(e); }
},
});
addCommand({
name: 'continueFromThePostReblogged',
command: function(stdin) {
try {
if (!stdin.length) stdin = window.Minibuffer.execute('current-node');
var url = $X(
[ './/div[contains(concat(" ", @class, " "), " post_info ")]',
'//span[contains(concat(" ", @class, " "), " reblog_source ")]',
'//a[contains(concat(" ", @class, " "), " post_info_link ")]' ].join('')
, stdin[0])[0].toString();
var postId = parseInt(url.match(/^http:\/\/[^\/]+\/post\/(\d+)/)[1]) + 1;
GM_openInTab('https://www.tumblr.com/dashboard/2/' + postId, true);
return stdin;
} catch(e) { console.log(e); GM_log(e); }
return stdin;
},
});
}
}
if (sharedObject.Minibuffer) {
boot();
} else {
window.addEventListener('GM_MinibufferLoaded', boot, false);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment