Skip to content

Instantly share code, notes, and snippets.

@disc99
Created October 22, 2014 12:58
Show Gist options
  • Save disc99/d5264cc8327249be4af2 to your computer and use it in GitHub Desktop.
Save disc99/d5264cc8327249be4af2 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Google search keybord shortcut
// @version 0.1
// @description Google search shortcuts
// @match http*://www.google.com/*
// @match http*://www.google.co.jp/*
// @copyright 2014+, disc99
// ==/UserScript==
// 指定のワードを追加/削除したURLへ移動
function forward(word){
var url = location.href;
if(url.indexOf(word) > 0){
document.location = url.replace(word, "");
} else {
document.location = url + word;
}
}
document.addEventListener('keydown', function (e) {
//検索ボックス以外
if( document.activeElement.id != "gbqfq"){
//key : shift
if(e.shiftKey == true ){
// key : 1
if(e.keyCode == 49){
//1年以内に絞り込み
forward("&tbs=qdr:y");
}
// key : 2
if(e.keyCode == 222){
//日本語のみに絞り込み
forward("&lr=lang_ja");
}
// key : 3
if(e.keyCode == 51){
//画像検索
forward("&tbm=isch");
}
}
}
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment