Skip to content

Instantly share code, notes, and snippets.

@thealanberman
Last active October 5, 2017 07:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thealanberman/e8b902b8b19636a7c4b08afb93c46140 to your computer and use it in GitHub Desktop.
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/
// ==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