Created
June 9, 2011 18:20
-
-
Save saitamanodoruji/1017369 to your computer and use it in GitHub Desktop.
pixiv Staccfeed 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 pixiv Staccfeed Tab Open to Continue to Dig | |
// @namespace http://www.pixiv.net/member.php?id=394375 | |
// @description Press "C", and you can continue to dig Staccfeed in new tab. | |
// @include http://www.pixiv.net/stacc* | |
// @author saitamanodoruji | |
// @version 0.0.1.20110610 | |
// ==/UserScript== | |
// dependent on Minibuffer and LDRize | |
(function() { | |
const KEY_TO_OPEN_IN_NEW_TAB = 'C'; | |
const KEY_TO_OPEN_IN_CURRENT_TAB = 'c'; | |
var boot = function() { | |
with (window.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(/^http:\/\/[^\/]+\/.*sid=(\d+)/) | |
|| stdin[0].getAttribute('id').match(/post(\d+)/) ) { | |
var postID = parseInt(RegExp.$1); | |
} else { | |
throw "I cannot get the postID."; | |
} | |
if ( args.length == 1 && args[0] == '-n' ) { | |
if ( window.location.href.match(/^http:\/\/www\.pixiv\.net\/stacc\/$/) | |
|| window.location.href.match(/^http:\/\/www\.pixiv\.net\/stacc\/my\/home\/all\/all/) ) { | |
GM_openInTab('http://www.pixiv.net/stacc/my/home/all/all/' + postID + '?no_update=1'); | |
} else if ( window.location.href.match(/^http:\/\/www\.pixiv\.net\/stacc\/my\/home\/all\/speak_simple/) ) { | |
GM_openInTab('http://www.pixiv.net/stacc/my/home/all/speak_simple/' + postID + '?noupdate=1'); | |
} | |
} else { | |
if ( window.location.href.match(/^http:\/\/www\.pixiv\.net\/stacc\/$/) | |
|| window.location.href.match(/^http:\/\/www\.pixiv\.net\/stacc\/my\/home\/all\/all/) ) { | |
window.location.href = 'http://www.pixiv.net/stacc/my/home/all/all/' + postID + '?noupdate=1'; | |
} else if ( window.location.href.match(/^http:\/\/www\.pixiv\.net\/stacc\/my\/home\/all\/speak_simple/) ) { | |
window.location.href = 'http://www.pixiv.net/stacc/my/home/all/speak_simple/' + postID + '?noupdate=1'; | |
} | |
} | |
} catch (e) { GM_log(e); } | |
}, | |
}); | |
} | |
} | |
if (window.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