Skip to content

Instantly share code, notes, and snippets.

@hokorobi
Created September 30, 2017 06:48
Show Gist options
  • Save hokorobi/ca1a075a4c294d6b4bddb75cecd07274 to your computer and use it in GitHub Desktop.
Save hokorobi/ca1a075a4c294d6b4bddb75cecd07274 to your computer and use it in GitHub Desktop.
Disable Autofocus
// ==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