From db3b4c1ced5fe033acc395561368df5b3afd6544 Mon Sep 17 00:00:00 2001 From: sharkpp Date: Tue, 5 May 2015 23:43:38 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=95=E3=82=A9=E3=83=BC=E3=82=AB=E3=82=B9?= =?UTF-8?q?=E7=8A=B6=E6=85=8B=E3=81=AB=E3=82=88=E3=81=A3=E3=81=A6=E3=82=B7?= =?UTF-8?q?=E3=83=A7=E3=83=BC=E3=83=88=E3=82=AB=E3=83=83=E3=83=88=E3=82=AD?= =?UTF-8?q?=E3=83=BC=E3=81=8C=E8=81=9E=E3=81=8B=E3=81=AA=E3=81=84=E5=A0=B4?= =?UTF-8?q?=E5=90=88=E3=81=8C=E3=81=82=E3=81=A3=E3=81=9F=E3=81=AE=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 ++++ src/userscript.user.js | 30 +++++++++--------------------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a5bf37..1986d91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 0.3 - 2015-05-05 + +* フォーカス状態によってショートカットキーが聞かない場合があったのを修正 + ## 0.2 - 2015-05-03 * ダッシュボードの変更に対応 diff --git a/src/userscript.user.js b/src/userscript.user.js index 15d79e8..77a5afd 100644 --- a/src/userscript.user.js +++ b/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 @@ -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) { @@ -146,5 +134,5 @@ } }); mo.observe(document.body, {childList: true, subtree:true}); - document.onkeydown = onkeydown; + document.addEventListener('keydown', onshortcutkey, true); })();