-
-
Save locopine/773ab9a53de1506fdd497be2d1ea4d9a to your computer and use it in GitHub Desktop.
Google slash search
This file contains hidden or 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