Last active
October 5, 2017 07:37
-
-
Save thealanberman/e8b902b8b19636a7c4b08afb93c46140 to your computer and use it in GitHub Desktop.
Amazon — focus on search box on page load. Jump to search box via '/' key. Unfocus with Esc key. https://userscripts-mirror.org/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Amazon Search Tweaks | |
// @namespace https://gist.github.com/thealanberman/e8b902b8b19636a7c4b08afb93c46140 | |
// @description Focus on search box on page load. Jump to search box via '/' key. Unfocus with Esc key. | |
// @include http://amazon.*/ | |
// @include https://amazon.*/ | |
// @include http://*.amazon.*/ | |
// @include https://*.amazon.*/ | |
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js | |
// @version 1 | |
// ==/UserScript== | |
$(document).ready(function() { | |
$("#twotabsearchtextbox").focus(); | |
}); | |
$(document).keyup(function(e) { | |
e.preventDefault(); | |
// 191 = forward slash key | |
if (e.keyCode == 191) { | |
$("#twotabsearchtextbox").focus(); | |
} | |
}); | |
$("#twotabsearchtextbox").keyup(function(e) { | |
e.preventDefault(); | |
// 27 = esc key | |
if (e.keyCode == 27) { | |
$(this).blur(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment