Created
January 19, 2020 22:26
-
-
Save caspark/cb561ce60629dd70ee7533af54828379 to your computer and use it in GitHub Desktop.
Google slash search
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 Google Slash Search | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://www.google.com/search* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
window.addEventListener("keypress", e => { | |
if (e.key == "/") { | |
const searchField = document.querySelector('#searchform input[type="text"]'); | |
searchField.focus(); | |
searchField.setSelectionRange(0, searchField.value.length); | |
e.preventDefault(); | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment