Skip to content

Commit

Permalink
フォーカス状態によってショートカットキーが聞かない場合があったのを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkpp committed May 5, 2015
1 parent 9df73c4 commit db3b4c1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
# CHANGELOG

## 0.3 - 2015-05-05

* フォーカス状態によってショートカットキーが聞かない場合があったのを修正

## 0.2 - 2015-05-03

* ダッシュボードの変更に対応
Expand Down
30 changes: 9 additions & 21 deletions src/userscript.user.js
@@ -1,7 +1,7 @@
// ==UserScript==
// @name Tumblr. extend shortcut key
// @namespace http://www.sharkpp.net/
// @version 0.2
// @version 0.3
// @description Tumblr. extend shortcut key for blog select and reblog button
// @author sharkpp
// @copyright 2014-2015, sharkpp
Expand Down Expand Up @@ -50,38 +50,26 @@
clickByXPath('//*[@data-js-' + act + ']');
clickByXPath('//*[@data-js-clickablesave]');
};
var onshortcutkey = function (e) {
var onshortcutkey = function (e) {//console.log(e);
e = e || window.event; // for IE
if (e.altKey) {
if (49 <= e.keyCode && e.keyCode <= 57) { // Alt + '1' ... Alt + '9'
if (0xE5 == e.keyCode) {
} else if (49 <= e.keyCode && e.keyCode <= 57) { // Alt + '1' ... Alt + '9'
var n = (e.keyCode - 0x30) - 1;
selectBlog(n);
return false;
} else if (82 == e.keyCode) { // Alt + 'r'
actionSelect('publish');
return false;
} else if (69 == e.keyCode) { // Alt + 'e'
actionSelect('queue');
return false;
} else if (68 == e.keyCode) { // Alt + 'd'
actionSelect('draft');
return false;
} else if (80 == e.keyCode) { // Alt + 'p'
actionSelect('private');
return false;
}
return true;
}
};
var onkeydown = function (e) {//console.log(e);
e = e || window.event; // for IE
if (e.altKey) {
if (0xE5 == e.keyCode) {
return false;
} else {
return onshortcutkey(e);
return;
}
} else {
return onshortcutkey(e);
e.preventDefault();
e.stopPropagation();
}
};
var addShortcutKeyElements = function (elm, keys) {
Expand Down Expand Up @@ -146,5 +134,5 @@
}
});
mo.observe(document.body, {childList: true, subtree:true});
document.onkeydown = onkeydown;
document.addEventListener('keydown', onshortcutkey, true);
})();

0 comments on commit db3b4c1

Please sign in to comment.