Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save syoichi/2963006 to your computer and use it in GitHub Desktop.
Save syoichi/2963006 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @id Add HatenaB keybind
// @name Add HatenaB keybind
// @version 0.0.1
// @namespace http://b.hatena.ne.jp/saitamanodoruji
// @author saitamanodoruji
// @description はてなブックマークにショートカットキーを追加する
// @include http://b.hatena.ne.jp/*
// @run-at document-end
// ==/UserScript==
// keybind
// m: 「みんなのブックマーク」を開く
// h: 「すべて表示」をクリックする
(function(win, doc){
doc.addEventListener('keypress', function(e){
GM_log(e.keyCode + ', ' + e.charCode);
if ( e.keyCode == 72 || e.charCode == 104 ) {
var trigger = doc.querySelector(
'h3.current-element ~ ul.entry-comment span.toggle-show');
if (trigger) trigger.click();
} else if ( e.keyCode == 77 || e.charCode == 109 ) {
var url = doc.querySelector(
'h3.current-element a.entry-link').href;
GM_openInTab(
'http://b.hatena.ne.jp/entry?mode=more&url='
+ url, true);
}
}, false);
})(window, document);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment