Skip to content

Instantly share code, notes, and snippets.

@Rahul-RB
Created March 17, 2020 04:27
Show Gist options
  • Select an option

  • Save Rahul-RB/f1ef8bd2261b8ba647ba0a11f7576175 to your computer and use it in GitHub Desktop.

Select an option

Save Rahul-RB/f1ef8bd2261b8ba647ba0a11f7576175 to your computer and use it in GitHub Desktop.
Mnemonic Dictionary Auto Focus Tamper Monkey Script
/* Install TamperMonkey
* Click on extension, create new script
* Copy paste the script from line 6 till end.
* Enjoy!
*/
// ==UserScript==
// @name Mnemonic Dict Auto Focus
// @namespace https://github.com/Rahul-RB
// @version 0.3
// @description Make input always focus
// @author Rahul R Bharadwaj
// @match https://mnemonicdictionary.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Your code here...
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");
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment