Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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