Last active
March 20, 2016 19:51
-
-
Save saitamanodoruji/911469 to your computer and use it in GitHub Desktop.
Tumblr Dashboard Tab Open to Continue to Dig
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Tumblr Dashboard Tab Open to Continue to Dig | |
// @namespace http://saitamanodoruji.tumblr.com/ | |
// @description Press "C", and you can continue to dig dsbd in new tab. | |
// @include http://www.tumblr.com/dashboard* | |
// @include http://www.tumblr.com/blog* | |
// @include http://www.tumblr.com/show* | |
// @include http://www.tumblr.com/likes* | |
// @include https://www.tumblr.com/dashboard* | |
// @include https://www.tumblr.com/blog* | |
// @include https://www.tumblr.com/show* | |
// @include https://www.tumblr.com/likes* | |
// @version 2.3.3 | |
// @update 2016-03-21 | |
// ==/UserScript== | |
(function() { | |
const KEY_TO_OPEN_IN_NEW_TAB = 'C'; | |
const KEY_TO_OPEN_IN_CURRENT_TAB = 'c'; | |
var boot = function() { | |
with (sharedObject.Minibuffer) { | |
addShortcutkey({ | |
key: KEY_TO_OPEN_IN_NEW_TAB, | |
description: 'continueToDig (new tab)', | |
command: function() { | |
try { | |
execute( 'continueToDig -n', execute('current-node')); | |
} catch(e) { GM_log(e); } | |
}, | |
}); | |
addShortcutkey({ | |
key: KEY_TO_OPEN_IN_CURRENT_TAB, | |
description: 'continueToDig (current tab)', | |
command: function() { | |
try { | |
execute( 'continueToDig', execute('current-node')); | |
} catch(e) { GM_log(e); } | |
}, | |
}); | |
addCommand({ | |
name: 'continueToDig', | |
command: function(stdin) { | |
var args = this.args; | |
try { | |
if ( execute('current-link').toString().match(/^https?:\/\/[^\/]+\/post\/(\d+)/) | |
|| stdin[0].querySelector('div.post').getAttribute('id').match(/post_(\d+)/) ) { | |
var postID = parseInt(RegExp.$1) + 1; | |
} else { | |
throw "I cannot get the postID."; | |
} | |
if ( args.length == 1 && args[0] == '-n' ) { | |
GM_openInTab('http://www.tumblr.com/dashboard/2/' + postID); | |
} else { | |
window.location.href = 'http://www.tumblr.com/dashboard/2/' + postID; | |
} | |
} catch (e) { GM_log(e); } | |
}, | |
}); | |
} | |
} | |
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