NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @author Rahul-RB // @name mnemonicdictionary.com Auto Focus // @namespace https://github.com/Rahul-RB // @version 0.3 // @description Make input always focus // @author Rahul R Bharadwaj // @match https://mnemonicdictionary.com/* // @copyright 2020, Rahul-RB (https://openuserjs.org/users/Rahul-RB) // @license GPL-2.0-only; https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html // @homepageURL https://github.com/Rahul-RB // @updateURL https://gist.github.com/Rahul-RB/f1ef8bd2261b8ba647ba0a11f7576175 // ==/UserScript== (function () { 'use strict'; var inputTag = document.querySelector("body > div.container.pt-4.pb-5 > div > div.col-lg-6 > ul > li:nth-child(1) > form > div > input"); console.log("Input Tag:", inputTag); inputTag.focus(); try { inputTag.onblur = function (e) { var elm = e.target; setTimeout(function () { elm.focus() }); } inputTag.onkeydown = function (e) { var key = e.which || e.keyCode; if (key == 9) e.preventDefault(); // code for tab is 9 } console.log("Events added successfully"); } catch (error) { console.log("Error attaching event listeners"); } })();