Created
September 30, 2017 06:48
-
-
Save hokorobi/ca1a075a4c294d6b4bddb75cecd07274 to your computer and use it in GitHub Desktop.
Disable Autofocus
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 Disable Autofocus | |
// @namespace http://github.com/hokorobi | |
// @version 0.1 | |
// @description Disable Autofocus | |
// @author hokorobi | |
// @include http://* | |
// @include https://* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
clearFocusElement(document.activeElement); | |
document.addEventListener('focus', clearFocus, true); | |
setTimeout(function(){ | |
document.removeEventListener('focus', clearFocus, true); | |
},250); | |
function clearFocus(e){ | |
clearFocusElement(e.target); | |
} | |
function clearFocusElement(elem){ | |
if(elem && elem.tagName && (elem.tagName.toUpperCase() == "INPUT")) { | |
elem.blur(); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment