Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Disable Focus on Window Load
- // @namespace http://userscripts.org/
- // @description Stop stealing focus and hotkeys
- // @include *://www.change.org/*
- // @include *://answers.yahoo.com/*
- // @include *://alternativeto.net/*
- // @include *://www.facebook.com/*
- // @include *://*.deviantart.com/*
- // @include *://*.yahoo.com/*
- // @include *://www.google.*
- // @include *://*thefreedictionary.com/*
- // @include *://github.com/*
- // @include *://imgur.com/*
- // @include *://www.merriam-webster.com/*
- // @run-at document-end
- // ==/UserScript==
- function disableFocus(evt) {
- if (evt.target.nodeName == "#document") {
- var input_elements = document.getElementsByTagName('input');
- for (var i = 0; i < input_elements.length; i++) {
- input_elements[i].blur();
- }
- }
- }
- if(document.URL.indexOf("www.google") >= 0)
- { document.addEventListener('keydown', function(e) {
- if (document.activeElement.nodeName != 'INPUT' && !e.ctrlKey && !e.altkey) {
- e.cancelBubble = true;
- e.stopImmediatePropagation();
- return false;
- }
- return true;
- }, true);
- }
- else if(document.URL.indexOf("imgur") >= 0)
- { document.addEventListener('keydown', function(e) {
- if (e.keyCode == 37 || e.keyCode == 39) { //disable left and right arrow keys
- e.cancelBubble = true;
- e.stopImmediatePropagation();
- return false;
- }
- return true;
- }, true);
- document.addEventListener('scroll', function(e) {
- e.cancelBubble = true;
- e.stopImmediatePropagation();
- return false;
- }, true);
- }
- else
- window.addEventListener('load', disableFocus, true);
Add Comment
Please, Sign In to add comment