Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save syoichi/2051916 to your computer and use it in GitHub Desktop.
Save syoichi/2051916 to your computer and use it in GitHub Desktop.
reblog machine で "o" キーで tumblelog を、"r"キーで reblog ページを開く
// ==UserScript==
// @id reblogMachineOpenDoor
// @name reblogMachineOpenDoor
// @namespace http://taizooo.tumblr.com/
// @author taizooo
// @version 0.0.2
// @update 2012-03-17T04:11:26.895Z(GMT+09:00)
// @description reblog machine で "o" キーで tumblelog を、"r"キーで reblog ページを開く
// @include http://reblog.machine.mamemomonga.com/dashboard*
// @run-at document-end
// @priority 0
// @compatibility Firefox 11.0(Scriptish 0.1.7), Chrome 17.0.963.79, Safari 5.1.4(NinjaKit 0.9.1), Opera 11.61 on Windows 7 Home Premium SP1 64bit
// @charset UTF-8
// ==/UserScript==
/*jslint browser: true, maxerr: 50, maxlen: 80, indent: 4*/
// Edition 2012-03-07
(function executeOpenDoor(win, doc) {
'use strict';
var postLink, reblogLink, openDoor;
postLink = doc.getElementById('avatar_tumblelog');
if (!postLink) {
return;
}
reblogLink = doc.getElementById('btns_pfunc_t_reblog');
if (!reblogLink) {
return;
}
openDoor = function openDoor(evt) {
if (
evt.target.tagName !== 'BODY' ||
evt.altKey || evt.ctrlKey || evt.shiftKey || evt.metaKey
) {
return;
}
switch (String.fromCharCode(evt.which).toLowerCase()) {
case 'o':
win.open(postLink);
return;
case 'r':
win.open(reblogLink);
return;
default:
return;
}
};
win.addEventListener('keydown', openDoor);
}(window, document));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment