Skip to content

Instantly share code, notes, and snippets.

@thealanberman
Last active October 5, 2017 07:37
Show Gist options
  • 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